PlayerAdded
doesn't work in a localscript, but I need a localscript in order to make my game work.
Can someone help me? This is what I have:
1 | --Location: game.Workspace |
2 | --This is a localscript |
3 | function plradded(plr) |
4 | local gui = Lighting.Gui:Clone() |
5 | gui.Parent = plr.PlayerGui |
6 | wait( 3 ) |
7 | gui = nil |
8 | end |
9 | game.Players.PlayerAdded:connect(plradded) |
The other way works, But easiest fix is changing PlayerAdded to ChildAdded. This should work in LS, and look like this...
1 | --Location: game.Workspace |
2 | --This is a localscript |
3 | function plradded(plr) |
4 | local gui = Lighting.Gui:Clone() |
5 | gui.Parent = plr.PlayerGui |
6 | wait( 3 ) |
7 | gui = nil |
8 | end |
9 | game.Players.ChildAdded:connect(plradded) |
Use two different scripts and then use RemoteObjects (RemoteEvent/RemoteFunction) if you need them to work together