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 10 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:

--Location: game.Workspace
--This is a localscript
function plradded(plr)
local gui=Lighting.Gui:Clone()
gui.Parent=plr.PlayerGui
wait(3)
gui=nil
end
game.Players.PlayerAdded:connect(plradded)

2 answers

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

The other way works, But easiest fix is changing PlayerAdded to ChildAdded. This should work in LS, and look like this...

--Location: game.Workspace
--This is a localscript
function plradded(plr)
local gui=Lighting.Gui:Clone()
gui.Parent=plr.PlayerGui
wait(3)
gui=nil
end
game.Players.ChildAdded:connect(plradded)

0
Oh, I didn't think of that. ChipioIndustries 454 — 10y
0
Thumbs up if you can xD MixCorp 70 — 10y
Ad
Log in to vote
2
Answered by 10 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 — 10y
0
Actually, that's good enough for me. Thanks! ChipioIndustries 454 — 10y
0
(RemoteObjects are used for server/client communication) RaverKiller 668 — 10y

Answer this question