How to Make Cars in Your Game Less Laggy


  • So I see some games that I really like has laggy cars, and I'm pretty sure they are laggy because the person who is driving the car is not taking network ownership. So, I wanted to make a tutorial for anyone who did not know about network ownership and how it can be used.

    So, the first thing to know is how Roblox handles physics. So, when a unanchored object comes near a client, the client handles the physics for the object. So, how is this related to cars? Imagine if you want to ride a car in Roblox with a friend, and you get in the passenger seat first. This would mean that you are handling the physics for the car, and not the driver. The reason this is a problem, is because what you are processing, the updates go to you first. If you live in different continents, it would take a few milliseconds for the passenger to send the updates to roblox's servers, and a few milliseconds to the driver. If the driver was taking network ownership, the driver would get an almost instant (if not instant) update, which would be important for like, anything that needs you to be going fast (like in a game that has police and stuff and you need to run away from police), as lag is bad in those cases. So, how do you set network ownership? You can set it by doing the following below and inserting the script in the driver seat. OWNER NETWORKSHIP CAN ONLY BE SET BY THE SERVER FOR SECURITY REASONS, but we are not a tutorial about bypassing the Filtering Enabled system.

    0_1504625484700_Codeshare.PNG

    So, whenever someone sits in the driver seat, they will handle the physics for them, and whenever they leave, the network ownership is automatic.

    I hope this tutorial helps you for making your cars driving smoothly!


  • You know a seats Occupant is the humanoid not the Player object which is what SetNetworkOwner requires.


  • @kingdom5 oops

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.