I am creating a punch tool that plays an animation on loop when you hold mouse1 and plays a punch animation when you release. I can’t tell what I did wrong with the script but I believe it has to do with lines 20-22.
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:WaitForChild(“Humanoid”)
local Holding = script:WaitForChild(“Holding”)
local anim = script:WaitForChild(“Punch”)
local anim1 = script:WaitForChild(“PunchReady1”)
local anim2 = script:WaitForChild(“PunchLaunch”)
local anim3 = script:WaitForChild(“PunchHold”)
local Punchdo = humanoid:LoadAnimation(anim)
local PunchReady = humanoid:LoadAnimation(anim1)
local PunchLaunch = humanoid:LoadAnimation(anim2)
local PunchHold = humanoid:LoadAnimation(anim3)
script.Parent.Activated:Connect(function()
Holding.Value = true
PunchReady:Play()
if Holding == true then
PunchHold:Play()
end
end
script.Parent.Deactivated:Connect(function()
Holding.Value = false
PunchLaunch:Play()
end)