Ad
Log in to vote
0

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

Asked by 7 days ago
Edited by Ziffixture 7 days 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 6443 — 7d
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 6443 — 7d

2 answers

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

Answer this question