Hello! I’m scripting an animation but is not working, when i click with my tool equipped, it doesn’t play the animation,
here’s the code:
local Character
local player
local ScriptsFolder = script.Parent
local Tool = ScriptsFolder.Parent
local AnimationFolder = Tool:WaitForChild("AnimationFolder")
local PunchAnimation = AnimationFolder:WaitForChild("PunchAnim")
local PunchAnimTrack
local Cooldown = false
local CooldownWait = 0.5
Tool.Activated:Connect(function()
Character = Tool.Parent
player = game:GetService("Players"):GetPlayerFromCharacter(Character)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
PunchAnimTrack = Humanoid:LoadAnimation(PunchAnimation)
end
end)
Tool.Equipped:Connect(function()
if Cooldown == false then
Cooldown = true
PunchAnimTrack:Play()
wait(CooldownWait)
Cooldown = false
end
end)
Did i index something wrong?