Diffrence between local functions and global functions

Hello Guys

For My Entire Scripting Journey I Never Noticed A Diffrence Between A Local Function And A Global Function

Can Somebody Explain it?

So if you have a local function, then the function can only be called in the code block that it was created in, and inferiors, while globals can be called anywhere
If Iā€™m bad at explaining, check this out.

2 Likes

thanks i really appreciate that

1 Like

In addition to the above, when you not use local you are technically overwriting a variable, this:

Something = function()
	print("Something")
end

is equal to this:

function Something()
	print("Something")
end

You can also check this

local function Example()
	print("Something 1")
end
print(Example) --> function: 0x8cfb13e15b91d402

function Example()
	print("Something 2")
end
print(Example) --> function: 0x0be947a3943cca82

and that roblox typecheck gives a warn

1 Like

intresting how it can print something way diffrent and overwrites it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.