Issues with changing player animations on collision

Hey, I am trying to change the player’s walk, run and idle animation upon colliding with an object. However, after setting the new animations; the player is just completely still without animation while moving.

local humanoid = script.Parent
humanoid.Touched:Connect(function(hit, limb)
	if hit.Transparency == 1 then
		return
	end
	
	if hit.Name == "CaptureTheFlag" then
		script.Parent.Animate.walk.walk.AnimationId = "rbxassetid://892267099"
		script.Parent.Animate.run:run.AnimationId = "rbxassetid://892265784"
		
		for _, child in pairs(script.Parent.Animate.idle:GetChildren()) do
			child.AnimationId = "rbxassetid://892268340"
		end
	end
end)
1 Like
script.Parent.Animate.run:run.AnimationId = "rbxassetid://892265784"

This line is an error

1 Like

To run an animation, please do:

 humanoid:LoadAnimation([[Animation Object]]):Play()
1 Like

I’ll try that when I am back into studio, thanks for the reply

1 Like