local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayToolAnimation")
local sound = tool:FindFirstChild("Sword Swing Metal Heavy")
local character
local humanoid
local moveConnection
local canAttack = true
local cooldownTime = 0.8
tool.Equipped:Connect(function()
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
RemoteEvent:FireServer("Idle", tool)
moveConnection = humanoid.Running:Connect(function(speed)
if speed > 0 then
RemoteEvent:FireServer("Moving", tool)
else
RemoteEvent:FireServer("Idle", tool)
end
end)
end)
tool.Unequipped:Connect(function()
if moveConnection then
moveConnection:Disconnect()
moveConnection = nil
end
RemoteEvent:FireServer("Stop", tool)
end)
tool.Activated:Connect(function()
if not canAttack then return end
canAttack = false
RemoteEvent:FireServer("Swing", tool)
sound:Play()
task.delay(cooldownTime, function()
canAttack = true
end)
end)
here is the problem:
you equip tool, idle plays, you start walking, moving anim plays, u stop walking, moving anim keeps playing and idle doesnt play
** You are now Level 3! **