Making an axe chop a tree

Trying to make an axe play an animation when clicked, and only when it is playing the animation it chops the tree.

(sorry i dont know much about animations but) I can play the animation on a local script but then I can chop the tree even when the swing animation isn’t playing. When I put it on a normal script, I can’t play the animation. I’m currently trying both and thats not working.

TL;DR, I’m using a local script and a script and it doesn’t work.

Local script:

local axe = script.Parent
local event = axe.RemoteEvent
local debounce = axe.Debounce
local player = game:GetService("Players").LocalPlayer
local character = game:GetService("Players").LocalPlayer.Character

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://79687356557379"


event.OnClientEvent:Connect(function(send)
	print("fired")
	local humanoid = character:WaitForChild("Humanoid")
	local animationTrack = humanoid:LoadAnimation(animation)
	animationTrack:play()
	event:FireServer()
end)

Script:

local axe = script.Parent
local event = axe.RemoteEvent
local debounce = axe.Debounce

game:GetService("Players").PlayerAdded:Connect(function(player, send)
	debounce.Value = false
	axe.Activated:Connect(function()
		event:FireClient(player, send)
		if debounce.Value == false then

			debounce.Value = true
			event:FireClient(player)

		end
	end)

	event.OnServerEvent:Connect(function()

		task.wait(1)
		debounce.Value = false	

	end)
end)

ok well you dont need to play the animation on the client, it works fine on the server as well. There are a few things that makes it better on the client, but when you’re simply making a tool swing animation it really doesnt matter.

The first thing I notice in your server script is that you have a player added event. You dont actually need this, since the tool is in the player’s character already. So you can just get rid of that line (and the end at the bottom)

Instead of using multiple remote events for the debounce, you should just use a cooldown of a few seconds like so:

debounce = true
--your tool code here
task.wait(1) -- the number being the cooldown time
debounce = false

Also when playing an animation it’s :Play() not :play()

I would get rid of the remote events entirely and just work from the server script inside of your tool. If you get more problems I also recommend looking at the output (error messages can be quite useful!)

there wasnt anything in output sorry for not stating that