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

Why doesn't my playeradded:connect function work?

Asked by 3 years ago

so ``function addSword(player) local backpack = player:WaitForChild("Backpack") local sword = game.ServerStorage.ClassicSword:Clone() sword.Parent = backpack end

game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(addSword()) end)``

This code doesn't work

but game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:Connect(function() local backpack = player:WaitForChild("Backpack") local sword = game.ServerStorage.ClassicSword:Clone() sword.Parent = backpack end) end)

this does, why is that?

0
CODE BLOCK Dovydas1118 1495 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

"connect" is deprecated. Use "Connect" instead.

Ad
Log in to vote
0
Answered by 3 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(addSword)
end)

You don't have to insert the ()

Answer this question