✓ Accepted answer
use PlayerAdded() and CharacterAdded. PlayerAdded is triggered in the Players when someone is added, and CharacterAdded is triggered when the Player spawns.
function addAnimation(character)
wait(1)
character:WaitForChild("Animate").walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?
id=1661650912"
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(addAnimation)
end)
I'll explain some other changes I did to your script.
I changed player at line 1 and 3 to character so it would detect the Character directly instead of having to get it through the player.
I changed Animate at line 3 to WaitForChild("Animate") because CharacterAdded fires before the animate script is loaded in. WaitForChild() will make the function wait until the animation script has loaded.
1 comment
Thank you kind person this was very explanatory :)