#who can help me to understand what is **return** in coding, thanks
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
hello guys and i need help
i need to understand what is return meaning in scripting
im watching theDevKing tutorials and i dont understand function repeat
ahhh
maybe i get it
@hot ravine
if my code looks like this
local function hello ()
print(`hi`)
return `awesome`
end
local hotdog = hello()
print(hotdog)```
why i need to write at the end local hotdog = hello()
wha
what
local function hello ()
print(`hi`)
return `awesome`
end
local hotdog = hello()
print(hotdog)```
whis is what i wrote
what about it
local function hello ()
print(`hi`)
return `awesome`
end
hello()```
ok
why cant i just write this
do you good at script?
yes
so look
when my code looks like this
it prints hi and awesome
but why it doesnt write awesome
** You are now Level 2! **
bc
ok
i explained it wrong
let me reexplain
do you understand what i mean?
local function getNumber()
local number = math.random(10)
return number
end
print(getNumber())
returning awesome basically sets the value of the function to 'awesome'
ig
;compile
8
yee
thats the explanation
but
why we cant jusy
wait i will recode it
oh wait
im more confuesd
confused
what
😭
it return a something
and stops code from running
it can either restart the code OR set value of smt
depending how you use it
thats the simplest explanation i can give
🙏
im so dump i cant understand it like second day
u have a ffunction
u execute a function and it runs it right?
by execute i mean call or whatever u name it
ok
ye so
and returning
do u know how functions work?
returns a value
like how to call it
local function?
local function sss()
end
sss()
yea yea
im know base i have learned it last week
and now im learning what i dont understand
return inside function, will stop the code (the function) running, and return a specific value (defined by you, or nil)
if you do
local test = sss()
and the sss function has a return
the test will be set to whatever the return returns
if u have a function
local function sss()
print("HI")
return true
print("HI AGAIN")
end
and do
local test = sss()
the function will normally be executed, but test will be set to true (as there is return true)
and u will only see "HI" not "HI AGAIN" as return STOPS rest of code from working (inside the function)
nice one @round talon
uhhhhhhh
@hot ravine thought this will happend
but work tho
what
ye so just remove 2nd print
wanted to show, that it wont work but its erroring
yes!
bc youre calling the function
and test is being set to true
bc
like i said
doing local test = sss()
will execute the sss function
and set the variable test to whatever it returns, in this case it returns true
bc returning true sets the value of the function to true
😭
what if
while false do
🙏
bro is breaking the universe
but i still dont understand btw
ye so no dont do that
bruh
@loud hamlet
who is this guy
local function sss()
local Number = math.random(1,10)
return Number
end
local test = sss()
print(test)
Try this
prodev2015?
mg gang
thats what i showed before
😭
i didnt read
i tried

🖕
returning in a function sets the value of the function to whatever you return
i dont understand what i dont understand
WHAt do you not FUCKING FUNDERSATND
but i dont understand something
what is it
what do you understand
I cant with this thread
😭
bc this kid is sped
last time
i tried to find it
** You are now Level 3! **
eee lvl 3😎
Also they said they'd give me Scripter 1 but they just closed my ticket and didnt give me scripter 1
if u do
local test = sss()
what will happend is
- sss function will be EXECUTED
- test will be set to WHATEVER the function returns (example. if function has return true, test will be set to true)
that means you got declined for s1
how does your s1 app get denied
They literally said that I was elligible for it
Good question
okay
so
local function sss()
local Number = math.random(1,10)
return Number
end
local test = sss()
print(test)```
bc, if u are s1, they know u only know enough for s1, when s0 can know as much as s4 (just not tested)
and bc with s0 u always say u are a ffucking moron and no one wil question
:D
why we need to write at the end
local test = sss()
print(test)```
write the print(test) ?
because calling the function isnt printing the value of the FUCKING FUNCTION
YOU IDIOT
lmao wtf
😭
the reason to why printing test at the end
is bc u cant print something, before u set it
widawwy
@hot ravine i think u need to take catnip i mean sealnip
or whatever its called
frfr
Yall this has been going on for so long I forgot what return does
im genuinely losing braincells from ts
i still dont get it
nvm
nah do you really think i get it
what the fuck do not get

to see if something was sucess for example
can you write example
function does something, and if it works fine it returns true
so if u see that it returned true, it means it sucessed
Is this kid trolling
wait stop confusing me
understand it
what language DO you speak
!!!! we spent over 250 messages explaining what return does!
local function returnValue (value)
print('hello')
value = math.random(10)
return value
end
print(returnValue()) -- printing this will print the value of the value variable we made within the function.
returnValue() -- running the function will print hello and and not print the value made within the function cause were not printing the function.
can we get it to sub 300?!
peep ts
Do you have an extra chromosome
;compile
function: 0x55a46eab3df0
hello
oops
what the fuck is value sir?!
WHERE IS LOCAL
OK
;compile
HERE IT IS
function: 0x5641cd564df0
hello
no but if i will understand return then i will get one
eh what ever
???????
i forgot ()
;compile
;compile
;compile
@upper canyon
Eat it 🌏
** You are now Level 5! **
this is not joke
r e a d
rip
wait, how old are you if i can ask..
the arm looks uhh
like u are not old enough to leggaly use discord
16
u either lying or that arm aint yours (on pic)
he has brain cancer
thats sad... but am talking about persons arm
yea
Ok I'm sorry about your dog and all but dont you think you're shifting the topic just a bit
its my sister
ah alr
dumbas
thought it was yours
dumbass
shut up
What is going on here
and lets talk about repeat
@upper canyon js read it
okay
return beats confusedkid
this guy dont understand returns even though we givin clear examples!?
(we going for sub 500 messages)
yes
we both ffucked up when showing the scripts btw
when
i did print after return
and u were printing function
not function()
You should leave before you start losing braincells

i swear if blud still doesnt understand it
uga booga, uga booga, @upper canyon , return is like your cat coming back with mouse in its teeth
the mouse is the returned thing
and in code , u set what the return should be
No hate but why are most people in the #1020374354867007528 forum illiterate
no
function add(num1, num2)
return (num1 + num2)
end
local result = add(1, 2)
print(result) -- 3
Just the people who ask the questions
my mother language is not english i can have some gramma problems
best example yet
Same my gramma lives in ukraine
wait im tryna to understand
‼️ ‼️ WE PASSED 350 MESSAGES EXPLAINING RETURN! ‼️ ‼️
;complie
gramatic
;coompile
ffuck
;compile
3
I'm stupid
wait this is really good for me
** You are now Level 4! **
But yeah that's basically that
u just lost braincells
function catgo()
local mouse = "mouse that was running a minute ago"
return mouse
end
local hello = catgo()
print(hello)
no
it will print "mouse that was running a minute ago"
Give up on game development
will not
How can you be this confused
I'm giving up, I'm putting @upper canyon for adoption
Not even
Lucky you, an AI took your adoption papers. Now read.
Im putting him down
Some random guy just DMed me asking me to play his shitty roblox game

we can just write
function catgo()
local mouse = "mouse that was running a minute ago"
return mouse
end
print(catgo())```
?
no
ngl I am no scripter, but even I don't know what return does
bro
sure
whyy no?
;compile
mouse that was running a minute ago
see
i meant yes but he keeps asking
Yall he's starting to understand
wait there is no diff ?
hold
Also we passed 400 messages
omg are u still confused?
local function test()
print("Hi")
return true
end
print(test())
test()
he keeps asking why not just print(test())
well, diffrence in output between
local test = catgo()
print(test)
and just print(catgo())
Is none, its same
but in first example u just have a variable set to it
@upper canyon You're the reason theres a "Do not drink" label on bleach
yes or
In LuaU, return is a special word used in functions. When a function finishes its job, it can use return to send back a result. For example, if you have a function that adds two numbers, using return lets you get the answer back so you can use it later. This helps keep things organized and makes it easier to do more with your code! So, whenever you see a return, think of it as a way for the function to say, "Here’s what I found!".
if u print the catgo()
vs
if you set variable test to catgo()
and print test
There is NO diffrence IN OUTPUT
but in 2nd example, you have a variable set to that, where in first u dont have a variable
thank you JeepBalls
BallsDeep
i fucking get it
LETS GOOOOOO
FINALLY
@hot ravine WE DID IT
YES
👏👏👏👏👏👏👏👏👏👏
time to leave this dumbass thread
It only took yall 425 messages to do it
nvm i quit
i will create other theme for it
so guys last one give me some tiny tasks that i can do with return
🖕
Dont talk to me ever again
@loud hamlet😏
return the value of pi from a math based func
ohhhh
thanks
finally i get it
make function which
creates a variable cookie with random value between 1 and 10
and if u have more then 5, it returns true
if less then 5, returns false
i think i confused u
It can also be used to stop a function from continuing by returning nothing, for example if it can't find the Player you can do: if not Player then return end
and like we said earier, return stops rest of code from running
so this will output nothing, and stop code from running
return, returns a value from a function for example
local function returnbanana()
local banana = "banana"
return banana
print(returnbanana())
reutrn
.
will know
@red kite
thanks
Np
yes?
Now get outta here
Nevermind
oke :p
** You are now Level 1! **
HOORAY
yes it isss
do u get it?
well no, your function name is not cook, i tried to say your function name and i got timedout for a minute (thats why i took a minute to respond)
the name of your function is uhhh ye
you mean?
how the hell did bro not get automodded
🤔
anyways u know what that means or no
