Ad
Log in to vote
1

Why doesn't my playeradded:connect function work?

Asked by 2 months 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 1460 — 2mo

2 answers

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

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

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

You don't have to insert the ()

Answer this question