Making spinners more performant

Hello!

I’ve recently come across an issue where spinners are causing massive amounts of lag and I can’t figure out what I’m doing wrong. I’ve since removed them from my game but since spinners are generally regarded as fundamental obby mechanics, I don’t know how long I can go without them.

Essentially, this is the hierarchy of my spinners:

Model
    CentrePart: ObjectValue
    Speed: NumberValue
    ClonedCentre (anchor)
         HingeConstraint
         Attachment
    Centre (acts as the sort of root of the spinner)
         Attachment
    Any number of parts which are all welded to Centre

Any ideas? It should also be noted that the objects are created on the client.

Serialize the spinner as a CFrameValue, have the server FireClient() to load the spinner when it detects a player near enough. Then you could use a Region3 on client to detect when the spinner is out of range, have them delete the spinner locally.

3 Likes

Seeing that your just using the physics engine of Roblox, just rotate their cframe, it should be less laggy

That’s a good idea actually, however I worry that constantly loading and unloading spinners would be laggy. Although maybe I could go based on what stage they are on.

@roby336, I can’t because it won’t carry the players.

1 Like

Since the server is doing the distance calculation, you can make the spinner a model, have it load in from ReplicatedStorage to the CFrameValues saved location as a :Clone(), or if you want to remove that tiny lag, have the model saved in Lighting or somewhere local, get that faster :Clone() Edit: Really and truly you could have the server detect players out of range too, it’s just a matter of how you handle your tables… I’m not good with my tables :confused:

1 Like

Instead of doing a Region3 check, I suggest doing a distance magnitude check. Especially if it turns out you need to check every frame (or every short amount of time), magnitude distance checking is far more optimized than a Region3 check, especially if the Region3 is big.