Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't my playeradded:connect function work?

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?

1 comment

0

CODE BLOCK

2 answers

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

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

You don't have to insert the ()

This discussion is preserved as it was. New answers, comments, and votes are closed.