#help with punching script.

10 messages · Page 1 of 1 (latest)

crude summit
#

im brand new to scripting and am following a video on adding a punch animation to my avatar. my avatar is not punching and im lost after using chatgpt and checking every line. heres the code:

local cas = game.GetService("ContextActionService")

local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local Punch1 = animator:LoadAnimation(script:WaitForChild("Punch1"))
local Punch2 = animator:LoadAnimation(script:WaitForChild("Punch2"))
--add other punches here:

local currentPunch = 0

local debounce = false

local function punch()
if debounce then return end

debounce = true
if currentPunch == 0 then
    Punch2:Play()
    task.wait(0.4)
    debounce = false
elseif currentPunch == 1 then
    Punch1:Play()
    task.wait(0.4)
    debounce = false
elseif currentPunch == 2 then 
    Punch2:Play()
    task.wait(0.8)
    debounce = false
end

if currentPunch == 2 then
    currentPunch = 0
else
    currentPunch += 1
end

end

cas:BindAction("Punch", punch, true, Enum.UserInputType.MouseButton1)

#

note: there is spaces between the equals, discord just doesn't show it.

golden raven
#

i suggest to use user input service

crude summit
#

trying to learn lol

golden raven
crude summit
golden raven
#

i don't have time to fully guide you through
so basically put your punch function in the uis input began

crude summit
#

uh alright. thanks for your help