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

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

Asked by 3 years ago
Edited by Ziffixture 3 years ago

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)
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. Ziffixture 6913 — 3y
0
Please do not criticize yourself for a mistake borne by inexperience; nobody will get it on their first attempt, not even software engineers. Ziffixture 6913 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

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)
Ad
Log in to vote
1
Answered by 3 years ago
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.Humanoid.WalkSpeed = 30
    end)
end)

Answer this question