【问题标题】:Gui opens for all players, but i did script in LocalScriptGui 对所有玩家开放,但我在 LocalScript 中编写了脚本
【发布时间】:2021-12-03 22:56:29
【问题描述】:
local prnt = script.Parent

game.Workspace.TeamChoose.Silents.Touched:Connect(function(hit)
    if hit.Name == "Right Leg" then
        prnt.Visible = true
        prnt.Silents.Visible = true
        prnt.Phantoms.Visible = false
    end
end)

我想让它只对本地玩家可见,但它对本地和其他玩家开放 我该如何解决?

【问题讨论】:

    标签: roblox


    【解决方案1】:

    您可以在部件内放置一个脚本,监听 Touched 事件,从 Touched 事件中找到玩家,然后给他们 GUI!

    local guiName = "" -- place gui name here
    
    script.Parent.Touched:Connect(function(hit)
        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        if player then
            local gui = player:WaitForChild("PlayerGui"):WaitForChild(guiName)
            gui.Visible = true
            gui.Silents.Visible = true
            gui.Phantoms.Visible = true
        end
    end)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-20
      • 2011-02-15
      • 1970-01-01
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      相关资源
      最近更新 更多