Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Question about the Tip of the Day?

Asked by
RedCombee 585 Moderation Voter
8 years ago
Edited 8 years ago

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!

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago
Edited 8 years ago

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.

Ad

Answer this question