I noticed that for today's tip, it advises using local variables over global variables. One of the mentions was lag, which I had not heard before.
In what way is
player = game.Players.LocalPlayer
worse than
local player = game.Players.LocalPlayer
in terms of lag? Would it make the actual server lag or just the script's rate of execution?
Note: I understand their value inside of loops, if statements, functions, etc. But outside of those things, what makes a global variable inferior?
Thanks!
This topic has been discussed with other administrators. If anything global variables make minimal impact to a game's performance however was added at our Tip of the Day list anyway. If you do manage to experience latency or performance issues using global variables, you are likely doing something completely wrong.
The deal is with global variables is you're comparing milliseconds to milliseconds. It just takes a few milliseconds longer for the global variable to be retrieved than the local variables. However as I had said if you manage to stack this, you are doing something.