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

Is running the same check twice across local and server a good idea?

Asked by 4 years ago

So this is something I've found myself doing recently that I haven't really seen elsewhere much so I'm kind of curious if it's a case of, it's good practice, bad practice, or just indifferent. Essentially the idea is that you run the exact same check in a local script as you would on the server side. So say I wanted to charge a player 50 bucks to buy an item in game. I'd of course check that on the server side to make sure they actually had that much.

if player.Money >= 50 then

But now what if I had the same check on the local side AS WELL? If the check fails, then it never goes to the server check in the first place but if it passes, it gets sent to the server to be checked again. Would this improve performance by having the server check less things, reduce performance being as it's now an extra check that has to be performed every time, or does it really have no overall effect?

0
It won't do anything too visible performance-wise, however if you can save a remote call, great! Hacreey 49 — 4y
0
I mean, you can, but I don't see why you wouldn't just use a remote function invoke. :InvokeServer then if the results return insufficient balance they don't have the access to whatever the purchased. Ethan_Waike 156 — 4y
0
Because that's the exact opposite of what I'm trying to achieve. I DON'T want the server to get involved if it doesn't have to. So for example, if we can clearly see on the client side the player doesn't have the money, then it won't even bother calling on the server to run a check on it's end. XxTrueDemonxX 362 — 4y

Answer this question