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

How can I make this loop repeat every 1 second?

Once I run through this script in test mode, there are no errors. The script still does not work though. What am I doing wrong?

local plr = game.Players.LocalPlayer
local g = plr:WaitForChild'stats'
local timemax = g:WaitForChild('timemax')
local countdown = g:WaitForChild('countdown')
local loaded = g:WaitForChild('loaded')

for i = 1,25 do
countdown.Value = countdown.Value +1
script.Parent.Size = UDim2.new(countdown.Value/timemax.Value,0,1,0)
wait(1)
end
if countdown.Value == 60 then
loaded.Value = true
end

The script is in a LocalScript and It is supposed to add 1 to the countdown value every 1 second, then when the countdown's value is 60, the "loaded" value is true. Which will complete the loading sequence in my game. Thank you for the help!

2 comments

1

Did you forget Parenthesis when you set the variable for 'g'?

0

Parenthesis should be fine, they're not always needed. Most of the time parenthesis are completely optional.

2 answers

✓ Accepted answer
  1. make sure the names of the objects you get using WaitForChild("") are correct

  2. try adding a print("") after each :WaitForChild("") to make sure you spelled it right

2 comments

0

Adding a print after using WaitForChild is completely useless. If the object WaitForChild is looking for doesn't exist, the script will never print the print statement because it's still waiting for the object.

0

Thank you for helping realize I had "timemax" instead of "maxtime" Lol.

add wait(1) after for i = 1,25 do

for i = 1,25 do
wait(1)

1 comment

0

What would that do?

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