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

My CharacterAdded Statement is not working. What did i forget?

I have a CharacterAdded script. I assume it's something wrong with the syntax, though, I'm unsure. What have I done wrong, can anyone give me some insight?

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait(function(char)
		char.Humanoid.WalkSpeed = 30
	end)
end)

2 comments

0

:Wait() is a method of RBXScriptSignal that yields the thread until a response is received. You've mistaken it for :Connect(), which is responsible for binding a Callback to the RBXScriptConnection.

0

Please do not criticize yourself for a mistake borne by inexperience; nobody will get it on their first attempt, not even software engineers.

2 answers

✓ Accepted answer

Just set char to plr.Character or plr.CharacterAdded:Wait()

game.Players.PlayerAdded:Connect(function(plr)
    local char = plr.Character or plr.CharacterAdded:Wait()
    char.Humanoid.WalkSpeed = 30
end)
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.WalkSpeed = 30
	end)
end)

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