Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is this how you make a combo punching system?

Asked by 6 years ago
Edited 6 years ago

So basically, I want it so that when you press q you punch once with one hand, then the second time you press q it punches with other hand. I've gotten answers on another question, but I cannot add it to this type of script can someone help me? How do I add an If statement to a mouse.Keydown ? Is there any syntax mistakes?

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
donefirstpunch = false

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=892155490"

local anim1 = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=897125858" 

    mouse.KeyDown:connect(function(key)
    if key == "q" then
        local playAnim = humanoid:LoadAnimation(anim)
        playAnim:Play()
        local donefirstpunch = true

    end
end)



if donefirstpunch == true then
    mouse.KeyDown:connect(function(key)
        if key == "q" then
            local playAnim1 = humanoid:LoadAnimation(anim1)
            playAnim1: Play()
            donefirstpunch = false
        end
    end)
end****

1 answer

Log in to vote
1
Answered by 6 years ago
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
move = 1 -- add this instead

local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=892155490"

local anim1 = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=897125858" 

    mouse.KeyDown:connect(function(key)
    if key == "q" and move == 1 then
        move = 2 -- change the value
    local playAnim = humanoid:LoadAnimation(anim)
        playAnim:Play()
    elseif key == "q" and move == 2 then 
     move = 1 -- change the value again, but to the left punch 
     --add block of code 
    end
end)
Ad

Answer this question