Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Why does it open a GUI for all players when 1 player touches a part?

Asked by
Rynappel 212 Moderation Voter
4 years ago

So I have a touch script and when you touch a part if shows a GUI. This is a local script in the Starter GUI and when you touch the spawn, it shows a GUI on everybody screens. How do I make it so it only shows it on the player who touched it?

Script:

game.Workspace.SpawnLocation.Touched:Connect(function()
    script.Parent.TeamGUI.ChooseFrame.Visible = true
end)

1 answer

Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
4 years ago

Maybe try using remote events:

MAKE SURE TO CREATE A REMOTE EVENT IN REPLICATED STORAGE CALLED: "RemoteEvent"!

Also put a serverscript inside the part

Server Script(inside the part)

script.Parent.Touched:Connect(function(touch)
    local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
    game.ReplicatedStorage.RemoteEvent:FireClient(plr)
end)

Local script(inside StarterPlayer.StarterPlayerScripts)

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
    script.Parent.Parent.PlayerGui.ScreenGui.Frame.Visible = true
end)
0
If this helped, mark this as the answer BashGuy10 384 — 4y
0
Thank you! Rynappel 212 — 4y
Ad

Answer this question