Although you do get “Global Variables” which are just variables without the local prefix, there is a way to make variables connectable throughout other scripts!
Caution
Although the server is safe, the client is not. Most exploiters that have client access are able to change both shared and global variables for the client, causing scripts to either break or not work. Use this as your own risk.
Shared
You can share anything using the following method:
shared["Name With Spaces"] = Value --| You can use brackets to fill in names with spaces.
shared.Name_Without_Spaces = Value --| You can use period keys without spaces.
--| You have to name the variable and give it a value like an ordinary variable.
shared.Uptime = 0
while task.wait(1) do
shared.Uptime += 1 --| Will count the server uptime and share to all scripts.
end
Obtaining Shared Variables
You can obtain the value from these shared variables by just calling them the same way you call a variable:
local currentUptime = shared.Uptime --| Obtains the Uptime variable
Global Variables
You can do the exact same as shared but instead of share you can just write this:
_G.Uptime = 0
while task.wait(1) do
_G.Uptime += 1 --| Will count the server uptime and share to all scripts.
end
Obtaining Global Variables
You can obtain them the same way as you obtain shared.
local currentUptime = _G.Uptime --| Obtains the global variable Uptime
Source is filled with other variables therefore I’ll just send a screenshot.