More optimal way to check and update data on the server?

So I’m making a UI-based game that is mostly client sided, but I still want to check and update values on the server so that they can’t be as easily exploited and so that leaderstats is visible for all players. I made a simple remote function that checks and returns a value to the client:

valueCheck.OnServerInvoke = function(player, object)
	return object.Value
end

There is also a function basically identical to that but that updates the value instead.

However, I have to call this multiple times to ensure that all the player’s requirements are met, and this leads to a noticeable delay (~.1 seconds) ever time that it’s called. Is there any way to check/update variables on the server without using so many remote functions/events, so that there isn’t such a delay with every action?

Is it possible you’re calling it a WHOLE bunch instead of just once?

a remote function shouldn’t cause any noticeable lag especially if you’re only calling it once

either put a print in the valueCheck or do

local t = os.clock()
valueCheck.OnServerInvoke = function(player, object)
	return object.Value
end
print(os.clock()-t)

and read the print to see how long in seconds it took for the valueCheck to run

In the place where the lag is most noticeable/important, I call valueCheck (remote function) 3 times and valueUpdate (remote event) 3 times, 1 each for 3 separate values. The time from the button being pressed to the script finishing is just over .05 seconds. Is 3 of each enough for the lag to be so noticeable? And if it is, do you have any ideas on a more efficient way to get it done?

Sorry, I’m having issues replicating the remote function and im out of time.

Im sure there are posts elsewhere of people talking about performance with remote functions and what not, im very suprised to hear that its taking that much time for each check.

Id recommend checking out Micro Profiler in the settings when you run the game

Go to modes → advanced

then invoke the server and pause the profiler with the button towards the right of the profiler ui.

There are forum posts on how to use it im sure, check those out and GL

Sorry I couldnt be of more help

I found a workaround that doesn’t require me to check the value on the server since that would be way too server intensive: whenever the value is changed, I make sure the client and server line up, and if not I change the value to what it says on the server. I don’t know how reliable this is but it works for now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.