#Need help with functions and its conditions

1091 messages · Page 2 of 2 (latest)

unkempt sage
#

let me

#

Replace the attack function only

lone verge
#
local combo = 1
local max = 4

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")

local function Counter()

    if combo < max then
        combo = combo + 1
    else 
        combo = 1
    end

end

local function Attack()

    if combo >= 4 then
        
        local Animation = script.Parent.Animations[combo]

        local animLoader = humanoid:LoadAnimation(Animation)
        
        animLoader:Play()

        

    else

        print(combo)

        if combo ~= 4 then

            Counter()

        end
    end
end


script.Parent.Activated:Connect(Attack)```
#

this right

unkempt sage
#

replace the attack function only

lone verge
#

LOOK AT THE SCREEN

unkempt sage
#

OH YEAA

#

Man if i team create with you

#

This Will be faster

lone verge
#

whats your roblox user

unkempt sage
#
       if combo > 4 then
          animation = script.Parent.Animations[combo]
          animloader = humanoid:LoadAnimation(animation)
          animloader:Play()
          Counter()
          else
         if combo == 4 then
             animloader:Play()
             script.Parent.Enabled = false
             humanoid.WalkSpeed = 0
             task.wait(4)
             humanoid.WalkSpeed = 16
             script.Parent.Enabled = true
             end
      end
end
    ```
#

that the new script

#

i cant on rn

#

new script

lone verge
#

it only does the fourth anim

#

once u do the first 3

#

where do i put the combo print thing so we can see the output

jovial canyonBOT
#

studio** You are now Level 9! **studio

unkempt sage
#

lol

lone verge
#

u see this

#

.

unkempt sage
#

Yes

#

The cooldown work on beginning?

lone verge
#

nope

#

the cooldown isnt working either

unkempt sage
#

wait

#

can you go to workspace

#

While playing the game

lone verge
#

can i what?

unkempt sage
#

go to workspace

#

While playing the game

lone verge
#

ig

unkempt sage
#

We need to see the tool is enabled or not

#

Properties

lone verge
#

where the backpack at

unkempt sage
#

Players

#

Click on players

#

In explorer

#

And click on your name

#

after that

lone verge
#

its working yea

unkempt sage
#

Click your backpack

#

try to 4 m1

#

And see if the tool.enabled become false

lone verge
#

YES IT DOES

#

look

unkempt sage
#

I cant

#

I always see your game

lone verge
#

then it gets enabled

unkempt sage
#

Let me search it up real quick

lone verge
#

but the problem is that when the tool is disabled

#

i can still click

#

on it

#

and it will start the cooldown

#

once again

#

instead of resetting the m1s

unkempt sage
#

i know

#

im searching the tool properties

lone verge
#

i gtg bro

#

try fixing the problem and when im back lets continue working on this shit

unkempt sage
#

haha

#

Got ideas

#

Might not efficient

#

But fuck it

lone verge
#

yes

#

this a whole chat now

lone verge
#
local combo = 1
local max = 3

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")

local function Counter()

    if combo <= max
    then
        combo = combo + 1
    else combo = 1

    end

end

local function Swing()

    local Animation = script.Parent.Animations[combo]

    humanoid:LoadAnimation(Animation):Play()
    Counter()

    print(combo)

end

script.Parent.Activated:Connect(Swing)

local function Cooldown()
    
    if combo == 4 then
        
        script.Parent.Enabled = false
        wait(4)
        script.Parent.Enabled = true
        
    end
    
end```
lone verge
#

took 15 tutorials and 3 different people

wraith turret
#

i can literally spot every issue

lone verge
#

on?

#

the new version

#

or the old

wraith turret
#

does it work tho?

lone verge
#

hell yea

#

like butter

wraith turret
#

gud

lone verge
#

wait i think this is an old version

wraith turret
#

🍔

lone verge
#
local tool = script.Parent
local combo = 1
local max = 3

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")

local swingTick = 0

local function Counter()

    if combo <= max
    then
        combo = combo + 1
    else combo = 1

    end

end

local debounce = false

local anim

local function Cooldown()
    
    if combo == 4 then
        
        script.Parent.Enabled = false
        wait(4)
        script.Parent.Enabled = true
        
    end
    
end

local function Swing()
    if debounce then return end
    debounce = true
    if tick() - swingTick >= 2 then
        combo = 1
        Cooldown()
    end
    local Animation = script.Parent.Animations[combo]

    anim = humanoid:LoadAnimation(Animation)
    anim:Play()
    if combo == 4 then
       Cooldown()
    else
       script.Parent.Enabled = false
       anim.Stopped:Wait()
       script.Parent.Enabled = true
   end 

    Counter()
    swingTick = tick()

    print(combo)
    debounce = false
end

script.Parent.Activated:Connect(Swing)


#

heres the new version

lone verge
wraith turret
lone verge
#

how

#

ill do it once i get on my pc

wraith turret
#

k

raven cliff
#

hi