【问题标题】:How do I make this code function correctly?如何使此代码正确运行?
【发布时间】:2020-02-10 15:56:29
【问题描述】:

我想在 Roblox Studio 中制作一种大厅系统,如果你有 4 个人在其中,你会被派往另一个地方。我试图为它建立一个系统,但它不起作用;你能帮我解决这个问题吗?

我试过让它在结尾显示 .Value。

local TeleportService = game:GetService("TeleportService")

player_amount = script.Parent.Parent.Parent.Player_Count
local placeID_1 = 4119652438
local function onPartTouch(otherPart)
    local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
    if player then 
        player_amount.Value = player_amount.Value + 1
    end
    if player_amount == 4 then
        TeleportService:Teleport(placeID_1, player)
    end
end


script.Parent.Touched:Connect(onPartTouch)

我希望输出为 0,然后如果有人踩到它,它会将标志更新为 1。但它只停留在 0。

【问题讨论】:

  • 在我看来,您正在增加 IntValue 或类似的值。如果您想更改标志,最好使用 .Text = etc... 引用文本

标签: lua scripting roblox


【解决方案1】:

这不是一个可行的解决方案,因为 .Touched 会在玩家触摸部件的每一帧触发,并且仅在他们移动时触发。我建议创建一个hitbox,就像我所做的那样here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多