Beams are desynced with the server

Hello, I am currently trying to make a 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()

	Character = C

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)))

local function MakeMarker(Position)
	local Marker ="Part")
	Marker.CanCollide = false
	Marker.CanQuery = false
	Marker.CanTouch = false
	Marker.Size =,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 ="Attachment")
	Attachment.Parent = Marker
	LastAngle = 0
	if #Markers ~= 0 then
		local Beam ="Beam")
		Beam.Attachment0 = Attachment
		Beam.Attachment1 = Markers[#Markers]:FindFirstChildOfClass("Attachment")
		Beam.Parent = Marker
		Beam.FaceCamera = true

local PreviousTime = os.time()
	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]
					if DegreesBetween < 3 and LastAngle < 3 then
						LastAngle += DegreesBetween
						Marker.Position = ConsideredPosition

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

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

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.