Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

trying to make it so the countdown gui doesnt start until the gui is enabled?

im trying to make it so the countdown doesnt start until the gui is enabled but i dont really understand if statements


local intermission1v1 = script.Parent

intermission1v1:GetPropertyChangedSignal("Enabled"):Connect(function(bool) if bool then do end end for i = 30,1,-1 do script.Parent.Text = i wait(1) end end

1 answer

✓ Accepted answer

Here is A Script This May Work

local intermission1v1 = script.Parent

intermission1v1:GetPropertyChangedSignal("Enabled"):Connect(function(bool)
      if bool then
            for i = 1,-30,1 do
                   wait(1)
                   script.Parent.Text = i      
            end
      end
end)

ok so since you said you don't understand if statements.

here is a video I recommend you watch to get a better perspective : (http://https://www.youtube.com/watch?v=5iQTzOaMjwE)

also on line one that would not be considered a function, not an if statement because your using the

:Connect

line 2 is checking if the UI is enabled

line 3 you had it a certain way before on the for I loop

so if you have your values 1,-30,1

the first number is the start value know as the start value that's how many times it repeats

so if you put that value as 2 you would have -60 and if you keep adding that up it would go on forever

and on the middle value known as the end value that's how many times the loop repeats

the increment value know as the last int this is from the dev hub :If the optional increment value is included in the statement, a positive value will count up while a negative value will count down

hope this helps! and i hope i explained this well!

3 comments

0

thanks for explaining it that helped alot! but when i put the script in it said that "Enabled is not a valid property name" for some reason but ill try to fix it

0

ok i recomend using the . changed function so intermission1v1.Changed:Connect(function()

0

i have tryed to do it using the :GetPropertyChangedSignal() and it usally fails

This discussion is preserved as it was. New answers, comments, and votes are closed.