BasePart "flickers" when both server and local are changing its properties

Hello. In my game i have two scripts that modify the same basepart at the same time, one is local, second is server, one changes position and second changes cframe


local star = workspace.FallingStar.FallingStar:WaitForChild("Star")

task.spawn(function()
	for i = 1,90 do
		task.wait(0.02)
		star.CFrame = star.CFrame * CFrame.Angles(0,math.rad(10),0)
	end
end)

task.spawn(function()
	for i = 1,90 do
		task.wait(0.02)
		star.Position += Vector3.new(0.5,0,0)
	end
end)

this is what happens when both position and cframe is being changed in the same script


Everything looks normal

this is what happens when actions are splitted between local and server script


star stars “flickering”

Ive heard it because of SetNetwork but im not sure. Even if it is, i cant change it because star has to be anchored. Is there a way to make it normal smooth while keeping them in seperate scripts like that?

When you change Position, you’re also changing the CFrame field. In essence, you’re getting two different CFrame values from the server and client, which are overwriting each other.

You should just do the rotation on the server. If you need rotation to only be clientsided, you’ll probably want to have the star have an Attachment parent that you modify the position of on the server, and have the client directly modify the BasePart star’s rotation.

One alternative might be using an event-based system, add a change callback to CFrame on the client and use that to update rotation (calculate delta time yourself).

1 Like

The problem is that a bunch of these stars are spawning and they lag the game (up to 50kb/s alone by these stars) i wanted to make rotation on the local side. So no server parts that update the position will work

but it will still mess with the main cframe that position also changes so it wont change anything

Why not just handle the CFrame on the client entirely? You can let the server store the Position, maybe with the use of an attribute, then just let the client do the rest.

Position is not replicated. It’s possible that the entire CFrame field is being replicated regardless if you rotate it or not (I’m not sure if they use any optimizations for this).

Fair, I might not have thought that fully through, but I think it’s still possible to hack if you do your math in a different way (rotate based on different from start time instead of delta time).

Another option might be using a LinearVelocity instance, maybe. The Attachment option still stands.

The main question of this topic is if there is a way to not do that fully on client side and not have a flickering, while still keeping performance, i was just curious if theres some easy fix for that, but i dont think there is.