I wrote a script for a punch tool with animations but gets this error:
code: ```lua
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local humanoid = char:FindFirstChild("Humanoid") or char:WaitForChild("Humanoid")
local tool = script.Parent
local animations = script.Parent.Animations
local rightPunch = humanoid:LoadAnimation(animations.RightPunch)
local leftPunch = humanoid:LoadAnimation(animations.LeftPunch)
local punch_anims = {rightPunch, leftPunch}
local canTouch = true
local punching = false
local crosshair = Instance.new("Frame")
crosshair.Name = "Crosshair"
crosshair.Size = UDim2.new(0, 10, 0, 10)
crosshair.BackgroundColor3 = Color3.new(1, 1, 1)
crosshair.BorderSizePixel = 2
crosshair.Parent = tool
tool.Equipped:Connect(function()
crosshair.Visible = true
end)
tool.Unequipped:Connect(function()
crosshair.Visible = false
end)
tool.Activated:Connect(function()
if canTouch and not punching then
local chosen_anim = punch_anims[math.random(1, #punch_anims)]
chosen_anim:Play()
canTouch = false
punching = true
wait(chosen_anim.Length)
punching = false
task.wait(0.2)
canTouch = true
end
end)