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

Is it possible to make script go back to certain line of code?

Asked by 4 years ago

I'm making a game where when the round ends, it resets back to the intermission and then another round begins. I have to make the game repeat, but I can't put everything in a loop because there's some issues with other loops and functions. Is it possible to do this:

[Intermission code]
[Map voting code]
[Winner code]
--Go back to line 1

If someone could help, that would be greatly appreciated!

2 answers

Log in to vote
1
Answered by 4 years ago

There is a way called loops. Loops are basically a line of code that repeats the same thing over and over again for a certain amount of time.

For loops for example repeat code for how many times you put it, like this:

for i = 1, 10, 0 do
--Code here
end)

You can watch PeasFactory's videos of loops, that's how I learned it.

https://www.youtube.com/watch?v=O2Ikk1JSInw

Theres also while true do loops which repeats code forever:

while true do
--code here
end
1
Theres also more loops like repeat and pairs loop, but i'm just showing you the basic idea of loops epic_4gaming 25 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I think you are looking for a function? If so try something like this:

local function newRound()
    --Code to repeat goes here
end

then you call the function whenever it is needed by typing

newRound()

so you get

local function newRound()
    --Code to repeat goes here
end

newRound() -- Runs it at the start

You may also want to check https://developer.roblox.com/en-us/articles/Function for more on functions, and https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events on how to activate it when needed!

Sorry if I was a bit vague on it, and that I couldn't give a sample code for Remote Functions and Events, but i'm still learning how to use them!

Hope this helped!

0
I'm pretty sure he was looking for loops. Loops can repeat code for a certain amount of time. Well, he can use another way, which is making a loop, and putting the function in the loop. epic_4gaming 25 — 4y
0
Judging by his example it could be either PoppyandNeivaarecute 134 — 4y

Answer this question