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

How do I make a gui appear for everyone when someone touches a part?

local script

game.Workspace.Checkpoints.Stage1.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		game.ReplicatedStorage.ShowGUI:FireServer(game.Players:GetPlayerFromCharacter(hit.Parent))
	end
end)

local script

game.ReplicatedStorage.ShowGUI.OnClientEvent:Connect(function()
	script.Parent.Frame.Visible = true
end)

Please give an explanation, I am new to scripting so I won't understand otherwise. Thanks!

2 answers

✓ Accepted answer

Your first LocalScript has to be a regular script, inside ServerScriptService.

3 comments

0

yea but then it says fireserver can only be called from the client

0

Change the local script to be a server script, then instead of FireServer do FireClient.

0

this will show to all players in the game right?

You can just use the local script to check if a part has been touched locally.

game.Workspace.Checkpoints.Stage1.Touched:Connect(function(hit)
	if game.Players[hit.Parent.Name] == game.Players.LocalPlayer then
		script.Parent.Frame.Visible = true
	end
end)

Also, local scripts only work when they're in the playergui, playerscripts, backpack and character. They will not execute anywhere else including serverscriptstorage or workspace.

1 comment

0
  • This would replace wherever the second local script you posted is.

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