I’m trying to make a LocalScript that makes the player play an animation when they join the game, The issue here is that Roblox’s output doesn’t want to tell me what’s wrong with my script, so I have no idea on how to fix the fact that the animation won’t play AT ALL when the player joins! I have tried so many Solutions, yet it refuses to work.
task.wait(1)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.WalkSpeed = 0
local anim = script.Animation
hum:LoadAnimation(anim)
anim:Play()
end)
end)
Before you ask, the script is in StarterPlayerScripts. I’ve placed it in multiple other places and yet none of them refuse to work.
It is not that, because the animation works perfectly fine on an NPC I made for the game and it doesn’t Override it. It’s the player-added thing but I have absolutely no idea how to fix it. It’s always the same junk with this player-added issue…
Try this in a LocalScript inside of StarterCharacterScripts to make sure the animation even works.
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local anim = hum.Animator:LoadAnimation(script.Animation)
anim:Play()
You’d be surprised as to how switching it to StarterCharacterScripts for the millionth time was the solution, thank you both a lot, but it’s strange how playeradded won’t run on PlayerScripts because
It worked when I switched up the walk speed strangely enough.