Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

printing a function?

Can a function have a value attached to it And if so how would you do that. I tried doing something like this

Function Example()
--Do Stuff
End

Print (Example)

And the output printed something about a table Followed by numbers and letters

1 comment

2

Lua is case sensitive, so "Function" needs to be "function", "End" needs to be "end", and "Print" needs to be "print".

1 answer

✓ Accepted answer

Yes, a function has a return statement. Note M39a9am3R's changes before doing this. What return will do, is return a value that you can either print or store in another variable

function Example()
	local a = 5+3;
	return a; -- we are returning the variable we just made
end

--you can do this
print (Example())

--or store it in another var
local OtherA = Example();

--You can return any types you want, whether it be CFrame values, Strings, decimals, integers, ect.

EDIT: Printing a function itself is about as useful as printing a Table. That is to say, not at all.

1 comment

0

thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.