#Repeat until working weirdly

195 messages · Page 1 of 1 (latest)

outer galleon
#

I made a button that whenever u click it does resizes the gui till its gone (its like a cooldown feature), once the cooldown is done and whatever and i click the button again the repeat until runs twice for some reason, i had tried breaking out of the repeat until loop and it doesnt really work as i thought it would.

#

this is my repeat loop thing for whenever i press the button


    if CanUseMove then
        
        repeat
            
            print("a")

            task.wait(cooldown/64)

            script.Parent.Parent.Transparency = .5

            script.Parent.Parent.Size = script.Parent.Parent.Size - UDim2.new(0,0,0,1)

            if script.Parent.Parent.Size.Y.Offset <= 1 then

                print("aaaaaa")

                script.Parent.Parent.Size = UDim2.new(0,64,0,64)

                script.Parent.Parent.BackgroundTransparency = 1
                
                break

            end
            
        until not CanUseMove
        
        return false
        
    end
next estuaryBOT
#

studio** You are now Level 1! **studio

primal dew
#

its repeating untill not CanUseMove

outer galleon
#

ye

primal dew
#

and u never changing it

outer galleon
#

im changing it in a different script

primal dew
#

bud

#

locals arent thro scripts

outer galleon
#

since this is in a module

primal dew
#

unless module

#

oh

#

wait tho

#

show me how u declared it

outer galleon
#

wym

#

im a newbie in this

primal dew
#

show me where u made the variable

outer galleon
#

so srry if i dunno

primal dew
#

the local

outer galleon
#

kk

primal dew
#

p sure u making it local

#

not modular

#

variable

outer galleon
#

i tried doing it in a module because

#

local

#

just

primal dew
#

yea yea

outer galleon
#

alr

primal dew
#

but dont think the variable is modular tho

outer galleon
#

too lazy to copy and paste

primal dew
#

in module

#

pls

outer galleon
primal dew
#

yea so

outer galleon
#

btw i only made the module to try and fix the issue

primal dew
#

u never updating it

#

sir

outer galleon
#

module isnt perm

#

what

#

lemme recheck

primal dew
#

tell me part where it sets CanUseMove to false or nil

outer galleon
#

bro i am a dumb ahh

primal dew
#

lol

outer galleon
#

i forgot to add it back in

#

but

#

hold on

#

lemme see if it works tho

#

wait no

#

it does upd

primal dew
#

so it works or no

outer galleon
#

now it broke

#

wait

#

lemme just

outer galleon
outer galleon
primal dew
#

i do not see lines

#

😭

outer galleon
#

oh shi

#

basically the part that says

GroundBoomCooldown = modf.Repeatable(2, GroundBoomCooldown)

#

my ahh is dumber than the 3rd grader coding on scratch ngl

primal dew
# outer galleon

if u are talking about return false part, all it does is stops script from running (which nothing in this case) and will set GroundBoomCooldown to the return, so false

outer galleon
#

oh

#

i gotta note something tho

next estuaryBOT
#

studio** You are now Level 2! **studio

outer galleon
#

even without the module script

#

i had the entire thing in the local script

#

the same bug was going on

#

put it back onto local script

#

and same issue is going on

primal dew
#

not sure what the issue is now tho

outer galleon
#

yeah thats why

#

this does check for if the cooldown is false or not

#

and it should stop accordingly, no?

#

not only that, but whenever the loop ends it should not restart

#

it does print after the loop ends

primal dew
#

am

#

kinda confused

#

u showwing very little parts of code

#

so am getting confused

primal dew
#

should be fine no?

outer galleon
#

yeah exactly what i was thinking

#

hold on lemme give some better explanations since i am only giving some brief sentences

#

UIS.InputBegan:Connect(function(key, typing)

if not typing then

    if key.KeyCode == Enum.KeyCode.One then

        if  GroundBoomCooldown == false then

                             --(in this part its where it checks whether the cooldown)

            game.ReplicatedStorage.Remotes.Attack:FireServer("SwordAreaGrounder")
            
            game.ReplicatedStorage.Remotes.Attack.OnClientEvent:Connect(function(cooldown, move)
                
                if cooldown == false and move == "SwordAreaGrounder" then
                    
                    GroundBoomCooldown = false
                    
                elseif cooldown == true and move == "SwordAreaGrounder" then
                                           --(checks for if u can do the move)                          

                    GroundBoomCooldown = true
                    
                    script.Parent.Size = UDim2.new(0,64,0,64)
                    
                    print("grgrgrgr")
                    
                    repeat
                        
                        print("a")  --(this is to check for each loop)

                        task.wait(2/64)

                        script.Parent.Transparency = .5

                        script.Parent.Size = script.Parent.Size - UDim2.new(0,0,0,1)

                        if script.Parent.Size.Y.Offset <= 1 then

                            print("aaaaaa") --(this works in the code, it checks if the size has reached the goal)

                            script.Parent.Size = UDim2.new(0,64,0,64)

                            script.Parent.BackgroundTransparency = 1
                            
                            GroundBoomCooldown = false --(this does as it says)

                        end
                        
                    until GroundBoomCooldown == false --(again)
                    
                    print("bababaa") --(checks for if the loop has ended or not)
                    
                end                    
                
            end)

        end

    end

end

end)

#

i put some comments

#

here and there

primal dew
#

yea so

#

now what

outer galleon
#

i literally do not know

#

why this bug is going on

primal dew
#

what bug tho

#

i still dont understand

outer galleon
#

alr

primal dew
#

i dont see the bug

outer galleon
#

basically there is a button that the player presses

#

and the gui has a red background that shrinks according to the cooldown

#

thats it

#

the repeat loop just doesnt end (i think thats the issue)

#

because if the player presses the button again

primal dew
#

do u get bababaa more times?

#

then 1

outer galleon
#

the loop from BEFORE activates

#

no

#

only once

primal dew
#

so loop only runs once

outer galleon
#

wait

primal dew
#

well only ends once

#

but

#

yea

outer galleon
#

wait

#

it prints twice

#

omfg

primal dew
#

u forgot to set it to true

#

the

#

Cooldown

#

or sum

outer galleon
#

no but i did though

#

in this

#

it does print everything in needs to print

primal dew
#

so the function runs more then once

#

the module

#

is that it rn?

outer galleon
#

since

#

it wasnt really

#

neccessary

primal dew
#

then the function with the untill

#

right?

#

it runs more then once

outer galleon
#

let me see

primal dew
#

isi that the problem?

#

am confused 😭

outer galleon
#

ask me some questions if u're confused

#

cuz

primal dew
#

just say whats the issue

outer galleon
#

im as confused as u are rn

primal dew
#

exacly

#

in code

outer galleon
#

the repeat until loop doesnt end

next estuaryBOT
#

studio** You are now Level 3! **studio

outer galleon
#

it works the amount of times u've pressed it in total

#

i am deeply sorry for my horrible explanations btw

primal dew
#

so it allows to execute the cooldown function more times

#

show script again

outer galleon
#

k

#

i will give u the whole script this time

#

`local player = game.Players.LocalPlayer
local char = player.Character
local UIS = game:GetService("UserInputService")
local modf = require(script.ModuleScript)

local GroundBoomCooldown = false

UIS.InputBegan:Connect(function(key, typing)

if not typing then

    if key.KeyCode == Enum.KeyCode.One then

        if  GroundBoomCooldown == false then

            game.ReplicatedStorage.Remotes.Attack:FireServer("SwordAreaGrounder")
            
            game.ReplicatedStorage.Remotes.Attack.OnClientEvent:Connect(function(cooldown, move)
                
                if cooldown == false and move == "SwordAreaGrounder" then
                    
                    GroundBoomCooldown = false
                    
                elseif cooldown == true and move == "SwordAreaGrounder" then
                    
                    GroundBoomCooldown = true
                    
                    script.Parent.Size = UDim2.new(0,64,0,64)
                    
                    print("grgrgrgr")
                    
                    --GroundBoomCooldown = modf.Repeatable(2, GroundBoomCooldown)
                    
                    repeat
                        
                        print("a")

                        task.wait(2/64)

                        script.Parent.Transparency = .5

                        script.Parent.Size = script.Parent.Size - UDim2.new(0,0,0,1)

                        if script.Parent.Size.Y.Offset <= 1 then

                            print("aaaaaa")

                            script.Parent.Size = UDim2.new(0,64,0,64)

                            script.Parent.BackgroundTransparency = 1
                            
                            GroundBoomCooldown = false

                        end
                        
                    until GroundBoomCooldown == false
                    
                    print("bababaa")
                    
                end                    
                
            end)

        end

    end

end

end)`

#

that

#

looks weird

primal dew
#

can i get in studio view

#

its easier for me

outer galleon
#

kk

#

do i like

#

take a SS

primal dew
#

tea

#

yea

outer galleon
#

serverscript from line 43 to line 61

primal dew
#

i dont see pressed code

outer galleon
#

o

#

right

#

i explained it

#

wrong

#

again

#

u press a key and it does

#

that

primal dew
#

oh

outer galleon
primal dew
#

dw

#

u got some remotes tho

outer galleon
#

ye

primal dew
#

and the rest of code triggers from remote on client

outer galleon
#

ye

primal dew
#

add checks

#

of the cooldown

#

after the on client event

outer galleon
#

alr

primal dew
#

just random idea

outer galleon
#

a check to see if cooldown is true or false?

#

ngl

#

im dumb at times

#

dont answer it

#

u gotta be fucking kidding me

#

a solution

#

was just

#

a

#

if cooldown = false

#

thank you bro

primal dew
#

dang