Gui 对所有玩家开放,但我在 LocalScript 中编写了脚本

Gui opens for all players, but i did script in LocalScript

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)

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

你可以在部件里面放一个脚本,监听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)