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

Why does this work in solo but not multiplayer?

Asked by
Ortron 27
9 years ago
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

Log in to vote
0
Answered by 9 years ago

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() )

0
Thanks, i'm sure I tried that before but I must have messed something up. Ortron 27 — 9y
Ad

Answer this question