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

My "3 hit sword combo" activates twice and doesn't function properly?

Asked by
3dsonicdx 163
9 years ago

So basically what the script does: Whenever I press "F" my character plays a animation and adds "1" to basic swingcombo. Basicswingcombo determines what animation and skill I am using. Function swingcombo() is basically the time the player has to use all three attacks before it resets back to the first one. In general - it's a combo move that the player has to use all three of the 'attacks' before the timer resets the skill.

During testing, it repeated the action twice, and did all three actions all at once instead of one action and then waiting on wait(0.6) delay to attack again.

player = game.Players.LocalPlayer
character = player.Character
mouse = player:GetMouse()
storage = game.ReplicatedStorage
basic = false
skill = false
basicswingcombo = 0 
local swordani = Instance.new("Animation")
swordani.AnimationId = "http://www.roblox.com/Asset?ID="
local swordani2 = Instance.new("Animation")
swordani2.AnimationId = "http://www.roblox.com/Asset?ID="
local swordani3 = Instance.new("Animation")
swordani3.AnimationId = "http://www.roblox.com/Asset?ID="


function swingcombo()
wait(2.5)
basicswingcombo = 0
print("swing reset")
end

function click()
end


function onKeyPress(inputObject, gameProcessedEvent)
    if character.Humanoid.Health > 0 and character:FindFirstChild("StunEffect") == nil and basic == false then
        if basicswingcombo == 0 then
        basic = true
        swingcombo()
        basicswingcombo = basicswingcombo + 1
        local animTrack = character.Humanoid:LoadAnimation(swordani)
        animTrack:Play()
        print("1")
        elseif basicswingcombo == 1 then
        basic = true
        basicswingcombo = basicswingcombo + 1
        local animTrack2 = character.Humanoid:LoadAnimation(swordani2)
        animTrack2:Play()
        print("2")
        elseif basicswingcombo == 2 then
        basic = true
        basicswingcombo = basicswingcombo + 1
        local animTrack3 = character.Humanoid:LoadAnimation(swordani3)
        animTrack3:Play()
        print("3")
        else
        basicswingcombo = 0
        print("Reset")
        end
        wait(0.6)
        basic = false
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

mouse.Button1Down:connect(click)
0
It looks like your swingcombo() is being fired any time you give any type of input - Focusing the game, tilting a device, clicking, moving, etc. User#6546 35 — 9y
0
Ok I'm a idiot. I accidently removed the key choice. Thanks for helping. 3dsonicdx 163 — 9y

Answer this question