Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

If this helped, mark this as the answer

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.