How to make smoother scripts

To all experienced developers out there! I’ve been trying to make my game less laggy and not take a heavy toll on client side. My game currently depends on the power of the device and internet that the player is using. I want to prevent that, however I am not sure what’s the best way to do it. Is it better using a server side script with remote functions? If not, what’s another best way to do it? Also does the amount of parts being loaded in game also affect the game? I recently came upon a post from @asimo3089 about converting a vehicle just to 4 parts but it looks almost the same exact thing as the one with more parts, but better. Thank you guys in advanced!

Hi,

It’s a very broad question you’re asking, with very little information about your game.

--Is it better using a server side script with remote functions?
  • Unable to answer that without more information.
-- Also does the amount of parts being loaded in game also affect the game?
  • Yes it does. You could turn on streaming enabled which will to some extend improve performance on the client.
--about converting a vehicle just to 4 parts but it looks almost the same exact thing as the one with more parts, but better.
  • Vehicles can be transformed into it’s most basic form. Chassis, Wheels & Seats. The rest can be done with tools within studios like VehicleSeat, Attachment ect.
1 Like

Client side should NOT be taking so much of a toll to the point where it actively bothers the game experience. If anything, the server should be doing some suffering more then the client with it’s free server hosting?

  1. Identify what is taking so much performance from the client, turn these things on. (under view)
    image
  2. Press play and check for multiple repeated scripts. (if there is 100 scripts of the same name, there is something wrong with that script, it should be slimmed down to 1 using whatever you need to use, collectionservice, object orientated programming with lua, etc)
  3. Check for scripts that run on a rate of 60+/s as they are using runservice functions which if they are performing intense enough operations or called throughout many scripts many times will cause lag.
  4. Delete these scripts causing severe client lag or any script that isn’t required or recognized causing a big % chunk of performance to be taken away.
  5. Check your game for viruses, using the find function type these keywords and scan them thoroughly.
  • loadstring (SHOULD BE REMOVED BASICALLY INSTANTLY)
  • require (investigate diligently before removing, especially with require(number))
  1. Check the other things like task scheduler.
  2. Repeat on the serverside too

Luau and the Roblox Engine should not be having such a hard time, as they are both surprisingly fast and efficient (for the most part)

As for

Also does the amount of parts being loaded in game also affect the game?

Yes, it does. It’s deprecated but every “thing” is measured by data cost (I think in KB). You can check the datacost of something by pressing play and in the command bar
image
image

As a test, type

print(workspace.DataCost)

and press enter, you can do this for any instance as well, serverstorage, repstorage, game, etc. The more parts, well, the more THINGS, the more datacost. You want to keep this number as low as possible and optimize as much as you can like 100s of the same script into one. Removing unnecessary parts, decals, textures, and more.

Also, enable StreamingEnabled by clicking on workspace and enabling that on the bottom, if it bricks your game then undo it.

1 Like

Thanks @TortenSkjold and @AIIusi_onist, I will try these suggestions.