How to make a part move via client to avoid Lag?

Hello! (Sorry if this is the wrong category, I don’t know if it will involve scripting)

Well … what’s my problem:

I am currently working on a game, and I am using a part move method through this:
image

But there is a problem, the block moves through the server, ie if the server is lagged, the block hangs, I wonder how can I do this move via client to avoid lag?

I would greatly appreciate your help! :slightly_smiling_face:

2 Likes

If you are using a Constraint in order to move your Part via ROBLOX Integrated Physics, just use SetNetworkOwner(plr). If you have multiple people that need to interact with the Part, you could use SetNetworkOwner(nil) in order to have the server maintain network ownership at all times.

You can read more about SetNetworkOwner here if you haven’t already.

1 Like

I want to get something like that.

While player 1 is seeing the block in one place, player 2 is seeing in another, so even if the internet of player1 or player2 is bad the block will not crash.

image

I wonder if SetNetworkOwner (plr) can do that.

Im fairly sure then you wouldn’t have to use set network owner in any way. It seems as though you would just have to position the part on the client . That way it could be different for each client.

1 Like

That’s how replication works. If you set the position of a part on one client, it won’t change on the other. If you change it on the server, it will change for all clients.

Whichever client “owns” the part is who decides where the part really is. There’s a better explanation here: Network Ownership | Documentation - Roblox Creator Hub under example 3.

2 Likes

Thank you very much! :slightly_smiling_face:

1 Like