How would i go about creating a vehicle dirtyness script

Hello! So i will keep it short.

I am trying to create a vehicle dirtyness script where the car gets more muddy the more you drive on grass and mud etc.

I cant think of any good way to make it work without using scripts that would make the games performance worse.

I know that you can use while true do or repeat until scripts to do this but is there some other less laggy way?

2 Likes

(Best performance I can think of) Have a table list of all vehicles in the game that will have this dirtiness effect, Magnitude check all players, Have a player folder that is empty in replicatedstorage with a unique identifier for that player, if a player is in range of a vehicle then create an ObjectValue and make it a child of your Folder, then have a local script that does Folder.ChildAdded(child) then once you have the child you can do .RenderStepped or .Heartbeat instead of while true do/repeat (which rely on wait() assuming your doing that (that is unreliable)

Essentially you will have 1 server script which logs every vehicle and magnitude checks all players for each vehicle, if a player is in range then create an Objectvalue for that vehicle in a unqiuely identified player folder in replicatedstorage (so the client can access the information) And then whilst there is a objectvalue do .heartbeat/renderstepped for for i,v in ipairs(Folder:GetChildren) do

– your code that makes dirt marks appear

(This is how I would do it let me know if you didn’t understand anything or if this doesn’t help with your question)

1 Like