#What is return and when should i use them
1 messages · Page 1 of 1 (latest)
like what is return for in these parts? Wouldn’t the script work even without them?
thats a simple assign plot on player join system btw
return is used for
to return a value from function
it is used to get a value from the function
so when he returns plotowners he can access that value in every part of the script?
and why does he return nil
return is the same as return nil
theres no reason to do that
the function's value becomes that
;compile
local function foo()
return 1
end
local var = foo()
print(var)
1
alr i’ve understood this
what can this be useful for?
like in the script i’ve sent
lots and lots of things
For example u want to find closest part
In few places in code
So you just make function that does that
And returns the part
Or u wanna format numbers to say 100k, 1m, not 100000 or 1000000
U just have function that does that and returns formatted
like i make the function calculatr player distance from a part in the workspace then i return that function and that function will be the actual distance
from what i understood
Oh I thought u meant return in general
Let me check your code
yes i mean return in general
but
even in that script i wanted to understand what return does there
so i can understand it
the get plot owners function?
yea the other ones too if u want
it returns the plot owners
here it takes in a plot, and returns that player's plot by looping through all of the plots until it hits a plot with the owner being that player
and if it doesn't find it, it returns nil
but thats completely useless since that would happen anyway
alright i kinda get it now
so by returning the plot
the plot will be = to player if i want to use it later in the script
what
how can you do that
wait
i understood what return does now
but by returning plot there
what i am achiewving