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

Why does this work in solo but not multiplayer?

wait(20) --I thought the script loaded before the server so I added a wait time of 25
print("5")
wait(5)
part=game.Workspace.PartOne --The part that changes the Gui when it is touched 
print("PartOne found")
player=game.Players.LocalPlayer
print("Player found")
print(player)

function touched()
	player.PlayerGui.ScreenGuiOne.Frame.Visible=false
	wait()
	player.PlayerGui.ScreenGuiTwo.Frame.Visible=true
	print("Text two.")
end
part.Touched:connect(touched)
	

It works in solo mode but whenever I play in multiplayer (1 person server) the Gui does not change. I've tried waiting 25 seconds before it searches for the player but it still doesn't work.

1 answer

✓ Accepted answer

You have used this property of a local script

player=game.Players.LocalPlayer

For this code to work, it must be placed within a localscript within the Player (so either put it in StarterGui or clone it into the player using :Clone() )

1 comment

0

Thanks, i'm sure I tried that before but I must have messed something up.

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