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

Why Wont This Code Work?

Asked by
StoIid 364 Moderation Voter
8 years ago
Edited 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

For some reason, the code just doesn't do anything after it prints "plr joined", any ideas why? Any other methods of getting this done?

local wings = script.StolidsWings
print('In here')

game.Players.PlayerAdded:connect(function(plr)
    wait(1)
    print('plr joining')
    if plr.Name == 'StolidDarkness' then
        wings:Clone().Parent = plr:WaitForChild('StarterGear')
        wings:Clone().Parent = plr:WaitForChild('Backpack') 
    end
end)

P.S. the script it's trying to copy is a LocalScript

0
Is the script that has this code a localscript? PlayerAdded doesn't work in localscripts. Operation_Meme 890 — 8y

2 answers

Log in to vote
0
Answered by
Bertox 159
8 years ago

try ChildAdded, just replace PlayerAdded with ChildAdded

Ad
Log in to vote
-1
Answered by
k1nq 30
8 years ago

Well, there is only one problem.

It is a very silly one at that, you set the thing that is getting cloned, wings, to local and it isn't inside of the game.Players.PlayerAdded. etc script itself, therefore it isn't going into it.

Just set "local wings = script.Stolidswings" to "wings = script.StolidsWings"

0
Local is just for efficiency, if the variable were created in the function then it would stick in that scope of just that function. However, since it was called outside of the function then it would be recognized by whatever that scope is. Since it is created outside of the function at the top of the script, the scope would be the script. M39a9am3R 3210 — 8y

Answer this question