I dont have anything to do with this but im pretty sure i will need it in the future to save time
So uh
How to make a global function like wait()?
You could use global variables, such as _G and shared.
But do something truly like wait() it will not be possible (i think)
As @PaintDevs said, you can use _G.
Here is an example of making a global function which can allow other scripts to access it since it’s global:
Script 1:
_G.Hello = function(Name)
print("Hello", Name)
end)
Script 2:
_G.Hello("Austin!")
Don’t use globals to “save time”. They’re not going to save you time and are bad practice in the Roblox environment, bringing a host of problems from race conditions to namespace collisions. If you need a reusable piece of code, look into ModuleScripts. You should never be using get/setfenv (deprecated) or the global table in 2023 besides backwards compatibility.
Its never a good idea to be using _G
, or Shared
, you should be using ModuleScripts
instead.
Oh no… why did I even write that… I literally have no idea why I posted that message and how I possibly forgot about ModuleScripts…
Thanks for picking up on this @colbert2677 and @DasKairo and reminding me that there’s a way better alternative.
For future viewers of this topic, definitely use ModuleScripts over _G. Here is the documentation for ModuleScripts: ModuleScript | Roblox Creator Documentation
Cant exploiters access module scripts?
They can access anything that’s replicated to their client. Exploiters aren’t a relevant concern here; if you’re worried that they’re going to overwrite a function, they are just as capable of doing so with a LocalScript. The changes will not propagate to other clients either.
Ok thanks
(32-2 characters limit)
What’s preventing you from using modulescripts? They’re exactly what you’re looking for but better.
Idk i just wanted to save time so i dont have to go pasting 200 lines of code in a function
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.