Bug happening when loading animation

Hey all, so my script isn’t working, and is giving me an error that I cannot understand very well.
I’m a beginner script, so please explain it to me in the most braindead way that you can. That would help me out a lot, and this bug has been annoying me for quite some time now, and it would be nice to finally squash it. Every attempt I do on this simply leads to me getting more annoyed at the challenge.

local clipProvider = game:GetService("AnimationClipProvider")
local tool = script.Parent
local explosion = game.ReplicatedStorage:FindFirstChild("RedExplosion")
local player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character

tool.Activated:Connect(function(hit)
	local animation = script:WaitForChild("Animation")
	local animator = Instance.new("Animator")
	local track = animator:LoadAnimation(animation)
	
	track:Play()
end)

1 Like

You’re supposed to use the animator inside character.Humanoid, so you don’t need to make your own.

local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

You don’t need the “clipProvider” service, to add on to this; Animators can only be parented inside of Humanoids/AnimationControllers.

Follow what J_Angry said!

Ah, thank you. I’m about to test it right now, I added the Clip provider service just as a kind of troubleshooting method.

There is no error, but the animation is not playing on the player.

Can we see your script?
It should just look like
local animator = path_to_character.Humanoid.Animator

local clipProvider = game:GetService(“AnimationClipProvider”)
local tool = script.Parent
local explosion = game.ReplicatedStorage:FindFirstChild(“RedExplosion”)
local player = game.Players.LocalPlayer

tool.Activated:Connect(function(hit)
explosion:FireServer()
local character = player.Character
local humanoid = character:WaitForChild(“Humanoid”)
local animation = humanoid:WaitForChild(“Animation”)
local animator = Instance.new(“Animator”)
local track = animator:LoadAnimation(animation)

track:Play()

end)

It seems like you’re trying to get the Animation from the Humanoid, when I meant you should get the Animator. Here’s the tool.Activated function updated:

tool.Activated:Connect(function(hit)
	explosion:FireServer()

	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	
	local animation = script:WaitForChild("Animation")

	local track = animator:LoadAnimation(animation)

	track:Play()
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.