local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Button1Down = mouse.Button1Down
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
local deb = false
local Slash = game.Workspace.Slash
local Tool = game.Players.LocalPlayer.Backpack.Tool
mouse.Button1Down:Connect(function(swing1)
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.animation)
if deb then return end
deb = true
animation:Play()
Slash:Play()
wait(3.25)
deb = false
end)
This is because you’re playing it whenever the player clicks instead of when the Tool is activated
Do Tool.Activated and then play the animation
Tool.Activated:Connect(function()
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.animation)
if deb then return end
deb = true
animation:Play()
Slash:Play()
wait(3.25)
deb = false
end)
I see a couple of things wrong here, so I’ll just go ahead & say them:
This will check if there’s a Character currently in the workspace, which is not guaranteed every time the script runs so you should probably implement a CharacterAdded:Wait()
event as well so that it can listen for that as well if your first value check doesn’t pass in
You’re listening for the Mouse’s Button1Down
Event, which will fire every time the left mouse is clicked regardless if the player has the tool equipped or not
There are no parameters for this Event, it’s not necessary to include a custom one
This is not a guaranteed & exact wait time
Put the script inside the Tool instead:
local Tool = script.Parent
local Slash = workspace.Slash
local Deb = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Tool.Activated:Connect(function()
local LoadAnim = Character.Humanoid:LoadAnimation(Tool.animation)
if Deb then
return
end
Deb = true
LoadAnim:Play()
Slash:Play()
wait(3.25)
Deb = false
end)
Thanks never knew that i am poo poo at scripting
No problem just keep working towards it