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

Is it possible to combine these two scripts?

Asked by 7 years ago
Edited 7 years ago

Is it possible to combine these two scripts? I tried, but there is the debounce problem. A debounce inside a debounce, wut?

local animation = Instance.new('Animation')
local animTrack
local debounce = false
local player = game.Players.LocalPlayer

function onEquip()
   script.Parent.Handle.UnsheathSound:Play()
end

function onActivate()
    if not debounce then
    debounce = true
    if player.Character:FindFirstChild('ForceField') then player.Character.ForceField:Destroy() end
    animation.AnimationId = "http://www.roblox.com/asset/?id=129967390"
    animTrack = player.Character.Humanoid:LoadAnimation(animation)
    animTrack:Play()
    script.Parent.Handle.SlashSound:Play()
    script.Parent.Handle.LocalScript.Disabled = false
    wait(0.5)
    animTrack:Stop()
    script.Parent.Handle.LocalScript.Disabled = true
    debounce = false
    end
end

function onUnequip()
    animTrack:Stop()
end

script.Parent.Equipped:connect(onEquip)
script.Parent.Unequipped:connect(onUnequip)
script.Parent.Activated:connect(onActivate)

and

local debounce = false
local player = game.Players.LocalPlayer

function onTouched(hit)
    if not debounce then
        debounce = true
        if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
            if hit.Parent.Humanoid.Health == 0 then
                player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16
            end
            wait(0.5)
            debounce = false
            elseif hit.Parent.Name:sub(1,4) == "Noob" then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
            wait(0.5)
            debounce = false
        end
    end
end

script.Parent.Touched:connect(onTouched)
1
Just make different debounces. AwsomeSpongebob 350 — 7y
0
^ koolkid8099 705 — 7y

Answer this question