How can I make this code less laggy?

Can you show the parts in a video?

Yes, Your script is fine , if this didn’t work then that’s some other issue

Okay sure. No problem.
(For the character stuffffffffff)

I’ll try your idea too.
(CHARACTERSSSSSSS)

it will be laggy because there is delay between the client and server, also the server runs at a lower fps than the client (most of the time)

This is not very accurate. The server doesn’t “run at a lower fps”. It’s the server. If anything it’s part of a powerful supercomputer somewhere in the Roblox server room. It doesn’t even have “fps” because it doesn’t do any simulations for itself. It simply just replicates states inside of itself to other clients. If anything, the client would have a lower fps than the server.

There is a small possibly that script could have lag, because you’re changing the property of an instance, every frame, literally every frame. So maybe, but it could just be an illusion, because there is no smooth movement between positions, it’s not lagging, just moving really fast.

Have you tried using a wait such as deltatime? Deltatime only works with RunService. If im pretty sure, deltatime is used to calculate FPS and could be useful to end slow and laggy scripts

1 Like

Sounds like this is a server-script, the server can skip some frames at times because the server has different tasks to deal with, try running it on the client-side instead, that should not lag or skip frames.

why are you making this in the server ?

what do you mean it doesn’t do any simulations

Which is what I’m saying. It doesn’t. It doesn’t have a framerate at all. There is no screen that shows what’s happening in game on the server. You’re giving out invalid information.

it is true that roblox servers do not render the graphics. However, they will still run a simulation of the world which will run a certain frequency otherwise how would spacial query API’s , such as raycasting , work on the server?

Here’s all I’m trying to say. If hypothetically the server was a player, and it could join games, there would be absolutely no way it would have a lower “frame rate” than the average player in the game. The server is a SUPERCOMPUTER. It is naturally more computationally effective than your average school computer. The server doesn’t or WOULDN’T have a lower rate than the client.

the server can in fact have a lower rate than a client if it is being loaded with heavy computations.

So sorry for such late replies. I had to do something all of a sudden. And sure I’ll try RunService, it was recommended to me before, but another person told me it didn’t reduce lag. So… I’ll try it I guess.

I’ve asked about this as well, and the answers I received were proving… kind of unknown? So I’ll try this too I suppose.

Okay so for some reason the picture won’t work. So I’ll just describe it. It’s like 25 long cylinders (Imagine prison bars). 25 or 30 Cylinders, and there are 8 rows of them. Each Cylinder has this script. (I changed each Row of Cylinders into MeshParts by the way.) They all have the same code I showed everyone earlier.

Like imagine a square wall, except it’s all made of cylinders.

Love how this topic died. :melting_face:
((((((((((((((((

It died because it’s solved. There’s no more fixing needed.