Animation script won't work on my sword please help

So my buddy spent a good deal of time with this script in replicated storage to animate a sword in starterpack, however, it won’t work. No animation plays. I’m wondering what’s wrong with this script. Thanks.

local repstorage = game:GetService("ReplicatedStorage")
local deb = game:GetService("Debris")
local ToolEquip = require(repstorage.Extensions.ToolEquip)
local user = require(repstorage.Extensions.UserObjects)
local cases = require(repstorage.Extensions.CaseHandlers.cases)



local melee = {}
local remote = repstorage.ServerCommunication.remotes.combat.combat
melee.CD = 0.24
melee.LastCD = 0.85
melee.WeaponLength = user.plr.Backpack.Zanpakuto.Handle.Size.Z



local ids = {
	"6031848899";
	"6030133585"	
}


function melee:FireToServer(cd)	
	print("Firing")
	remote:FireServer(20,self.WeaponLength)
	wait(cd)	
end

function melee:load_animation(id)
	local anim = Instance.new("Animation")
	anim.Parent = user.char
	anim.Id = ("rbxassetid://%s"):format(id)
	print(("rbxassetid://%s"):format(id))
	deb:AddItem(anim)
	local track = user.hum:LoadAnimation(anim)	
	track.Priority = Enum.AnimationPriority.Action	
	return track
end

function melee:play_animations(attempt)
	cases(self,ids,attempt)
end

function melee:run()

	local firing = 0
	local debounce = true
	local mouse = user.plr:GetMouse()	
	local tool = user.plr.Backpack.Zanpakuto
	local CanAttack = false
	local attempt = 0
	
	
	mouse.Button1Down:Connect(function()
		if (debounce) and (firing % 5 ~= 0) and ToolEquip(tool,CanAttack) then
			debounce = false	
			attempt += 1
			self:play_animations(attempt)
			self:FireToServer(self.CD,firing)
			firing += 1
			debounce = true
		elseif (debounce) and (firing % 5 == 0) and ToolEquip(tool,CanAttack) then
			debounce = false
			attempt = 0
			self:play_animations(attempt)
			self:FireToServer(self.LastCD)
			firing += 1
			debounce = true
		end	
	end)	
end

return melee
1 Like

Instead of using humanoid; since that way is being depreciated… (beats me why)

Try referring to the animator located as a child to the humanoid.

aka

Humanoid.Animator:LoadAnimation

(Also; have you tried detecting the mouse click from the sword itself? Add a debounce and you are set.)

APIs to refer to:

(basis understanding)
local tool = --tool
local hum = – use the code you were using before
local animator = hum.Animator
tool.Activated:Connect(function()
animator:LoadAnimation()
–Continue code
end)

If that does not work try setting the animation priority to action, it may still be on idle and you wouldn’t know it.

1 Like