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

How do you make a localscript function with PlayerAdded?

Asked by 11 years ago

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
3function plradded(plr)
4local gui=Lighting.Gui:Clone()
5gui.Parent=plr.PlayerGui
6wait(3)
7gui=nil
8end
9game.Players.PlayerAdded:connect(plradded)

2 answers

Log in to vote
1
Answered by
MixCorp 70
11 years ago

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
3function plradded(plr)
4local gui=Lighting.Gui:Clone()
5gui.Parent=plr.PlayerGui
6wait(3)
7gui=nil
8end
9game.Players.ChildAdded:connect(plradded)
0
Oh, I didn't think of that. ChipioIndustries 454 — 11y
0
Thumbs up if you can xD MixCorp 70 — 11y
Ad
Log in to vote
2
Answered by 11 years ago

Use two different scripts and then use RemoteObjects (RemoteEvent/RemoteFunction) if you need them to work together

0
I don't know what RemoteObjects is, would you mind explaining? ChipioIndustries 454 — 11y
0
Actually, that's good enough for me. Thanks! ChipioIndustries 454 — 11y
0
(RemoteObjects are used for server/client communication) RaverKiller 668 — 11y

Answer this question