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

How do I loop a script or part of the script? I need help!

Asked by
AbeTGT 4
4 years ago

So, basically, I need to know how to loop my script. I'm making a countdown for my game, and it's actually important to the game. Here's the script I want to repeat:

--//Variables
local DuelGUI = script.Parent.Parent
local Script = script.Parent.DuelHandler
local CountdownVal = script.Parent.Countdown
local YesandNoFrame = script.Parent.YesAndNo
local DuelTextText = script.Parent.DuelText
local DuelStartingCountdownVal = script.Parent.DuelStartingCountdown
local Player = script.Parent.Parent.Parent.Parent

--//The coding part
repeat wait()
    wait(1)
    CountdownVal = CountdownVal - 1
    DuelTextText.Text = "Duel starting in "..CountdownVal "..."
until CountdownVal == 0

if CountdownVal == 0 then
    DuelTextText.Text = "A duel is starting in "..CountdownVal " seconds. Would you like to enter? 5 players max."
end

repeat wait()
    wait(1)
    DuelStartingCountdownVal = DuelStartingCountdownVal - 1
    DuelTextText.Text = "Duel in progress... "..CountdownVal " seconds left"
until DuelStartingCountdownVal == 0

if DuelStartingCountdownVal == 0 then
    -- This part, I need to repeat
end

On line 28, i need it to loop the script, or just loop from line 10 to 29 over and over again. But I don't know how to do it. While true do, perhaps? Here's a screenshot of where everything is located: https://bit.ly/2Y7IFL7 If anyone can help, please do. Thanks =)

0
Are you using a Server Script in the GUI? If you are, use a local script. Also, you can use repeat until() for the part you need to loop. ChristianTRPOC 64 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Here

--//Variables
local DuelGUI = script.Parent.Parent
local Script = script.Parent.DuelHandler
local CountdownVal = script.Parent.Countdown
local YesandNoFrame = script.Parent.YesAndNo
local DuelTextText = script.Parent.DuelText
local DuelStartingCountdownVal = script.Parent.DuelStartingCountdown
local Player = script.Parent.Parent.Parent.Parent

--//The coding part
repeat wait()
    wait(1)
    CountdownVal = CountdownVal - 1
    DuelTextText.Text = "Duel starting in "..CountdownVal "..."
until CountdownVal == 0

if CountdownVal == 0 then
    DuelTextText.Text = "A duel is starting in "..CountdownVal " seconds. Would you like to enter? 5 players max."
end

    wait(1)
    DuelStartingCountdownVal = DuelStartingCountdownVal - 1
    DuelTextText.Text = "Duel in progress... "..CountdownVal " seconds left"
until DuelStartingCountdownVal == 0

if DuelStartingCountdownVal == 0 then
while true do
    print("Looping...")
    wait(0.5)
    end
end
0
@Officer_DuckyC ok.. but can you grab my script and put it inside there? I'm tired, and I can't really focus while I am. Thanks anyway =) AbeTGT 4 — 4y
0
k DuckyRobIox 280 — 4y
0
Fixed DuckyRobIox 280 — 4y
Ad

Answer this question