Does GOTO exist in roblox?

I’m a new scripter and my first language was Qbasic back in school.

So, in Qbasic you can use “GOTO” which basically takes you to the specified line of code. I used this and if then else to code a quiz thingy in Qbasic.

Example : GOTO 65
(takes you to line number 65 in your code and does whatever is in line 65)

Can this be done in Roblox?

2 Likes

No sadly.

But there’s always a way to counter GOTO and replace it with something else such if statements or functions.

1 Like

This is probably achievable with functions, like so:

local e = "hi"
if e == "hi" then
    jump()
end

local function jump()
    h.Jumping = true
end
1 Like

OP was asking if you can execute specific lines, like with GOTO in qbasic, he was not talking about CTRL+F.

Example of GOTO in qbasic:

1 PRINT "first line" : GOTO gohere
2 PRINT "second line": GOTO 3

gohere:
PRINT "third line"
GOTO 2

3 END 

Output:

first line
third line
second line

He want’s to accomplish something like this, but with Lua.

Oh, alright. I have a very little amount of experience in programming.

You’re looking for functions.

local function sayHello()
    print("Hello!")
end

sayHello() --> "Hello!"
1 Like

Goto was added in Lua 5.2. Roblox Luau is based off of Lua 5.1 and they have already said they will not port goto back. See the Luau compatibility page for more info.

14 Likes

You could just copy paste a line to the command bar.

CTRL + G
:arrow_up:Lets you go to a specific line of your script

Is this what u ment? (Then u can copy this line into command prompt)