So that I may use them in any script in the place, including LocalScripts and server Scripts.
I made a global function using _G in a LocalScript, but when I tried to call it on a server Script, it failed.
(I would post this in a comment if I had 10+ reputation) I'm fairly sure you cannot specify a global functions (and global variables) in a localscript. Try putting it into a normal one:
_G["hellomynameisfunction"]=function() print("WHOA MAN I JUST DID SOMETHING") end _G.hellomynameisfunction()
Very simple,
_G["FunctionName"] = function(argument1,argument2) print("Code Goes Here Yada Yada") end
Then to call it, You use...
print("GUYS IMA DO SOMETHING GLOBAL!") _G.FunctionName("Somethingthere","somethinghere") print("I Did It")
You could also do something like,
_G["IsOwnerHere"] = function() is = false for i,v in pairs(game.Players:children() do if v.userId == game.CreatorId then is = true end end return is end
Then if your in the game
B = _G.IsOwnerHere() --B = true