I donāt really understand what you fully mean, maybe this?
local function assert()
local function printStr(m: string)
print(m)
end
while #game.Players:GetPlayers() > 0 do
printStr("Welcome")
break
end
end
Possibly that?
local function returnName(p)
return p.Name
end
local function assert(name)
return name
end
game.Players.PlayerAdded:Connect(function(player)
assert(returnName(player))
end
That could also work. If you need anything else, or this wasnāt what you were looking for, let me know! (You can always hit me up in DMs! )
Well from what I believe I know, it would just be a cleaner way of displaying the code. A function would be the same as adding the code directly to that line, but just represented by a function instead. (Basically, whatever is in the function will run as the function on that line.)
If none of that made sense, hereās a visual:
local function PrintHelloWorld()
print("Hello world!")
end
game.Players.PlayerAdded:Connect(PrintHelloWorld)
-- Would be the same as
game.Players.PlayerAdded:Connect(function(player)
print("Hello world!")
end)
Somewhat, yes. This would error, because itās not hooked to HttpService, and not wrapped in quotes, but yes. If you returned it, it would look like this:
local function tostringl()
return "https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#tostring"
end
print(tostringl())
-- Would be like doing this:
print("https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#tostring")
A function is basically a way to run code on a single line, making the code cleaner, and more efficient. Itās better to have a single line, rather than multiple lines, with the same code.
A function is a cleaner way to run code. Nothing that special, lol.
function someFunction()
ācode here
end
print(someFunction) āwill print the address
print(someFunction()) āactually calls the function and prints whatever it returns.
0xe59cdfe707cd724a is not the binary that is the address in memory
-- save this function into myFunction variable
-- myFunction points to a location in memory
local myFunction = function()
print("This is my function")
end
-- this will print the location of the function in memory
print(myFunction)
-- and we can call that location in memory like this
myFunction()
You simply cannot convert it into a function. Think of a memory address as a table and an index, with the address being an index and the function being the value. You canāt āconvertā the address into the value, you first have to index the hypothetical table with the address to get the function. Obviously Iām oversimplifying it incredibly, thatās not actually how memory is stored.