AlignPosition - Lag/Desync problem

Lately, I was learning how to use forces to do a rolling object that alternate between two points, at first I was using BodyPosition, but then changed to AlignPosition because I started to encounter some issues with it. AlignPosition worked very good, the only thing I needed to do was a script to change the point CFrame that has the Attachment1, so that way, the rolling object moves it’s position to a single point. I did this for every instance in the game that has certain tag. It worked perfectly, until I started to notice something. After a time of playing, it seems that some rolls started to desync and working with stutter physics.

You can see this in the video below:

The gray squares you see is just to take their CFrames to pass it to the Attachment1 part. I’m pretty sure this is not a script-related thing, since it works fine when I execute the game, the phenomenon just appears after a bit of playing, but anyways, here it is:

-- services
local servCollection = game:GetService("CollectionService")

while wait() do
	for _, v in pairs(servCollection:GetTagged("tag_roll")) do
		local marks = v.marks:GetChildren()
		local magnitude = math.floor((v.mask.Position - v.reach.Position).Magnitude)
		
		-- Alternate "reach" position between the two marks
		if magnitude <= 0 then
			if v.reach.Position == marks[#marks].Position then
				v.reach.Position = marks[1].Position
			else
				v.reach.Position = marks[#marks].Position
			end
		end
	end
end

That’s not the only problem, I didn’t recorded a video for this, but when I execute the game, in that time lapse before the physics seems to break, the humanoid can push any part just like nothing, however, when that time lapse is reached, the humanoid oddly can’t push any of the rolling parts anymore. I tried many things to fix it but nothing seems to work.

Something to clarify, I’m not a very good scripter, so maybe this is something to do with my incompetence to write code.

2 Likes

I also have desync issue sinde 2 weeks. My AI seems to be desync randomly.

1 Like

I to have been getting the same problem with my models but they seem to work perfectly out of studio (when trying to play a public session) hopefully someone have a fix for this its working my brain >-<.

For all the moving Unanchored parts try setting
Part:SetNetworkOwner(nil) if not specified it’s set to auto. Setting it nil will make the physics the servers responsibility. It’s resolved my issue which is similar to yours. Figured I’d come back to your post and share

3 Likes