I've had this script work before, I am trying to make a sword that will play an animation when clicked. I also wanted the sword to take more damage. Sadly, the script will not run when I click. Here's the script:

local tool = script.Parent.Parent.Parent

local cooldown = script.CoolDown.Value

local animation = script.Swing

local hit = script.Parent.Touched


tool.Activated:Connect(function()

	local humanoid = tool.Parent:WaitForChild("Humanoid")

	if humanoid and cooldown == false then

		cooldown = true

		animation.AnimationId = 5658842541

		local damage = hit.Parent:FindFirstChildWhichIsA("Humanoid")

		local animtrack = humanoid:LoadAnimation(animation)

		animtrack:Play()

		damage.Health = -4

		wait(1.5)

		animtrack:Stop()

		wait(2)

		cooldown = false

	end

end)


Please, any help would be appreciated.

4 comments

0

Local script or Server Script? Animations replicate to the server when you play them. Also make sure you set the PRIORITY. If the priority is low, then it will be overridden by the roblox default animations.

0

I am using a Server Script, the animation priority is set as an ACTION. It still does not work, even after uploading a new one and changing the id

0

are you getting any errors in the output?

0

I am getting no errors in the output.