Weird client to server motor replication bug(s)

Hello! I have been having some weird lag-back trouble with my server-sided ELS handler which has resulted in some unintended behaviors from the motors.

The way it is supposed to work is the following:

  1. It sets the motors desired angle
  2. Waits for that angle to be reached
  3. Sets new color/maxvelocity
  4. Repeat

And this will run until killed by external factors.
Now the biggest problem I am currently facing is that for some reason the client likes to change the directions the motor is spinning…

The second problem I am facing is that sometimes depending on the angle the motor will just glitch back and forth on the server meaning it never hits the epsilon.

The current code for this function is the following:

while RunService.Stepped:Wait() do
	if rotatorTable.run == false or lights[lightName].running_module ~= patternModule then
		break
	else
		local desiredAngle = lightData[rotatorTable.currentRunner].angle % 360
		local currentAngle = math.deg(motor.Motor.CurrentAngle) % 360
		if math.abs(currentAngle - desiredAngle) < 0.05 then
			motor.Motor.MaxVelocity = 0
			motor.Motor.DesiredAngle = math.rad(desiredAngle)
			motor.Motor.CurrentAngle = math.rad(desiredAngle)
			print(motor.Motor.DesiredAngle, motor.Motor.CurrentAngle, desiredAngle)
			task.wait()

			if rotatorTable.currentRunner >= rawlen(lightData) then
				rotatorTable.currentRunner = 1
			else
				rotatorTable.currentRunner += 1
			end

			patternModule.moduleSettings.light(
				lightParts[lightName],
				lightData[rotatorTable.currentRunner].color,
				patternModule.moduleSettings.colors
			)
			motor.Motor.MaxVelocity = lightData[rotatorTable.currentRunner].velocity
			motor.Motor.DesiredAngle = math.rad(lightData[rotatorTable.currentRunner].angle)
		end
	end
end

The surrounding code is available at Emergency-Vehicle-Creator/src/ExportTemplates/EVCPlugin.luau at 883d67874fddb0349df069a4610e247a73f28fb7 · Redon-Tech/Emergency-Vehicle-Creator · GitHub
Please note that the changes in the code snippet above are not available on GitHub yet.

Thank you in advance!

Well this was never answered, here is the solution I eventually ended up with

Roblox motors are janky and so I just got rid of relying on the motor portion and basically just used them as welds :person_shrugging:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.