Car becomes unpredictable on lower-end devices

For the past few days I have been trying to find a way to prevent a car from spazzing while driving it.

I have taken the jeep model from the toolbox (which is also findable in the default game template “Suburban” in Roblox Studio) and I have tested this vehicle on different devices and I stumbled across a problem which can cause serious issues to players with lower-end devices.

On my computer the car drives perfectly fine. However, on lower-end devices, the car tends to become unpredictable and undriveable; it begins spazzing around.

I think this is happening because some lower-end devices can’t handle the calculations the script is trying to perform each renderstepped:wait() which in time causes lag and miscalculations causing the car to become undriveable.

To simulate this problem I’ve added a serverscript in workspace:

while true do
	wait()
	print("test")
end

The longer this script runs, the higher the ping and the more the vehicle becomes unpredictable.

Looking at the performance of the scripts used in the vehicle (a localscript and serverscript), you can see that there are no remarkable findings. The rate and activity are in between 0 and 2%, which should be fine.
image

image

It seems that I’m right to assume that the more lag the server has, the worse the driving gets.

Is there a way to prevent this car from spazzing whenever the server or client can’t handle the calculation?

Video of the car spazzing out:
robloxapp-20201216-1906340.wmv (2.7 MB)

link to the model in toolbox:
https://www.roblox.com/library/290307816/Jeep

1 Like

I’d recommend increasing the time between calculations. For example, just add a toggle or ticker that runs these calculations once every 3 steps, rather than every step. Also, avoid using wait(no arg) in while loops.

Increasing the time between calculations causes the vehicle to not drive smoothly. The while true do example was purely used for the sake of simulating the spazzing.

Really? The difference between, say, 1/60th of a second and 1/20th of a second is negligible. Also, are you using the deltatime argument?

1 Like

Implementing a toggle to run the calculations 3 steps results in ever more unpredictable behaviour (I’ve just tested it). Taking this response in consideration acts as even more proof that the spazzing behaviour is caused by lag or calculation inconsistency.

I haven’t heard of deltatime until now. I will look into this and see if this could be a possible solution.

EDIT: increasing the time between the calculation has a possitive correlation with inconsistency which means that the higher the time waited between calculations, the higher the unpredictability of the car behaviour