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)