#return

35 messages · Page 1 of 1 (latest)

lament dew
#

how to make return work only when the function is executed?

lunar pilot
#

what

#

expand?

humble apex
lament dew
lament dew
#

when I click play it immediately prints 5

humble apex
lament dew
#

and how can I fix it??

humble apex
#

local a2 = test() will save the value the function returns

#

not the function

#

local a2 = test will save the function

lament dew
#

oh

humble apex
#

so you'll able to do this

#
local a2 = test
local result = a2()  --> 5
lament dew
#

thank you

humble apex
#

no worries

humble apex
#

if it does not return anything it'll just run the function but the variable will be nil

lament dew
#

oh okay thank you

dusty sphinxBOT
#

studio** You are now Level 7! **studio

humble apex
#

no worries

#

Although functions are very important, I recommend you don't get too ahead of yourself

lament dew
#

yea

humble apex
#

they are actually the last thing you would ideally learn, the problem here is that you are learning scripting for roblox instead of programming concepts

#

well "problem"

#

just a piece of advice you did not asked for

lament dew
humble apex
#
- What is an algorithm
- What are data types and why they exist
- What are variables, and why they are used, and how they work
- printing
- how logic flows (literally how scripts are read by the interpreter)
- Prepositional logic, and if statements
- scopes
- While loop and Repeat until loop
- basic data structures (roblox language, Luau only has one, tables, but there are many!)
- for loops
- functions

if you are curious

#

that's the ideal order

#

notice how this has nothing to do with roblox

#

but with programming

#

if you know these, you can script basically anywhere, not just in roblox

#

hope it helps, good luck