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 2 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 — 2y

2 answers

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

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

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

You don't have to insert the ()

Answer this question