Animation are only working on upgrades past #1?

Hey, so I am making a tower defense game and I made an animation. I Tried printing out “Animation running” after I play it and that does show up in the output. When I upgrade the tower to tier 2 it works, but on the first one it doesn’t even play, but it says it is. Any idea why?

game:GetService("ReplicatedStorage").Placement.Events.Attack_Animation.OnClientEvent:Connect(function(name, object, sound)
	if not script:FindFirstChild(name) then return print("COuld not find animation: "..name) end
	if not object:FindFirstChild("Humanoid") then return  end
	if not game:GetService("ReplicatedStorage").Placement.Sound:FindFirstChild(sound) then return print("Cannot find sound"..sound)end
	local Sound = game:GetService("ReplicatedStorage").Placement.Sound:FindFirstChild(sound):Clone()
	Sound.Parent = script
	Sound:Play()
	wait(.8)
	Sound:Destroy()
	local Anim = object.Humanoid:LoadAnimation(script[name])
	Anim:Play()
	
end)```
game:GetService("ReplicatedStorage").Placement.Events.Attack_Animation.OnClientEvent:Connect(function(name, object, sound)
	if not script:FindFirstChild(name) then return print("COuld not find animation: "..name) end
	if not object:FindFirstChild("Humanoid") then return  end
	if not game:GetService("ReplicatedStorage").Placement.Sound:FindFirstChild(sound) then return print("Cannot find sound"..sound)end
	local Sound = game:GetService("ReplicatedStorage").Placement.Sound:FindFirstChild(sound):Clone()
	Sound.Parent = script
	Sound:Play()
	wait(.8)
	Sound:Destroy()
	local humanoid = object:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	local Anim = animator:LoadAnimation(script[name])
	Anim:Play()
end)

Your animation is either broken, incompatible with your character model or some other unforeseen reason.

I’m not to sure if this will help, but this is a video of the issue. https://gyazo.com/f7066467752cbd99fb6704563ccaee34

Hey, I’d recommend changing the anim line. Humanoid:LoadAnimation is deprecated, which means if it breaks roblox wont fix it. Then your game will break. So I’d recommend changing it. Here’s the recommended way from roblox. Go to your character(tower) and scroll down to the humanoid and click on the plus on the side
image
click on it and search “Animator” and insert it.
image
Next go to your script and type this

local object = script.Parent
local Humanoid = object:FindFirstChildWhichIsA("Humanoid")
if Humanoid then
	local Animator = Humanoid:FindFirstChildOfClass("Animator")
	if Animator then
		local anim = Animator:LoadAnimation(Animation)
		anim:Play()
	end
end

I’m pretty sure this won’t fix your issue. But will insure your script won’t break in the future due to a roblox update.

1 Like

I had already added those lines.

I didn’t notice that when I was typing it. But I went into in detail on how you can add it and why u do so.