Beams are desynced with the server

Hello, I am currently trying to make a Paper.io game in roblox. I have two problems:

First of all, as you can see in the picture sometimes when the block curves, the beams are not perfectly lined up. How would I fix this?
Here is the script for the creation of the beams:

local Players = game:GetService("Players")
local Runservice = game:GetService("RunService")
local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

Player.CharacterAdded:Connect(function(C)
	Character = C
end)


local REFRESH_RATE = 0 -- how often does it check the character's position
local RESOLUTION_DISTANCE = 1 -- how far does the character need to be from its last position to make a new point



local Markers = {}

local LastAngle = 0


function DegreeBetweenVectors(a, b)
	return math.deg(math.acos(math.clamp(a.Unit:Dot(b.Unit),-1,1)))
end

local function MakeMarker(Position)
	local Marker = Instance.new("Part")
	Marker.CanCollide = false
	Marker.CanQuery = false
	Marker.CanTouch = false
	Marker.Size = Vector3.new(0.1,0.1,0.1)
	Marker.Color = Color3.fromRGB(255, 0, 0)
	--Marker.Transparency = 1
	Marker.Anchored = true
	Marker.Position = Position
	Marker.Parent = workspace
	local Attachment = Instance.new("Attachment")
	Attachment.Parent = Marker
	LastAngle = 0
	
	if #Markers ~= 0 then
		local Beam = Instance.new("Beam")
		Beam.Attachment0 = Attachment
		Beam.Attachment1 = Markers[#Markers]:FindFirstChildOfClass("Attachment")
		Beam.Parent = Marker
		Beam.FaceCamera = true
	end
	table.insert(Markers,Marker)
end

local PreviousTime = os.time()
Runservice.Heartbeat:Connect(function()
	if PreviousTime + REFRESH_RATE < os.time() then
		if Character then
			local ConsideredPosition = Character:GetPivot().Position
			if #Markers == 0 or (ConsideredPosition - Markers[#Markers].Position).Magnitude >= RESOLUTION_DISTANCE then
				local PreviousMarker = Markers[#Markers]
				if #Markers >= 2 then
					
					local DegreesBetween = DegreeBetweenVectors(ConsideredPosition - PreviousMarker.Position,PreviousMarker.Position-Markers[#Markers-1].Position)
					local Marker = Markers[#Markers]
					print(LastAngle)
					if DegreesBetween < 3 and LastAngle < 3 then
						LastAngle += DegreesBetween
						Marker.Position = ConsideredPosition
						return
					end
				end
				MakeMarker(ConsideredPosition)
			end
		end
	end
end)

Also, another problem is that for some reason the creation of the beams are desynced with the server

image
as you can see here, it looks fine
However on the server, the beams and the block are desynced. Why is this?
image

I am using :MoveTo() to move the block

Thanks in advance for any help

As for the Beam’s curving around corners, do you have an individual Attachment for each end of each beam, or are you using a new Attachment0 and Attachment1 for each Beam? If not try using the Attachment1 of the previous Beam as the Attachment0 of the next beam. You may also want to change the Orientation of the Attachment to split the difference between the previous Beam end angle and the next Beam’s start angle.

1 Like

for the desync you can handle the visuals on client (handle for each player) but still keep track of them on server (for validation of kills etc)

1 Like

I have already done this, but I still have the problem.

I am handling the creation of the beams on the server, but the problem is that its desynced

so handle the creation on client then? and keep the server one if you need validations like touching events (but make the beam/parts invisible)

1 Like

I currently only have the server one handling the beams, however the problem is that on the server the beams are desynced. There is no problem on the client.