Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How come my remote controlled vehicle is delayed?

So I made a car completely using joints and constraints. However, I noticed that in order to operate like a car, I must make a script that operated the joints:

local seat = script.Parent
local car = workspace:FindFirstChild("Car_"..script.Parent.Owner.Value)

local function onChanged(property)
	if property == "Steer" then
		local SteerAngle = car.SteerAngle.Value
		car.Angle.Value = seat.Steer*SteerAngle
	end
	if property == "Throttle" then
		local MaxSpeed = car.MaxSpeed.Value
		car.Speed.Value = seat.Throttle*MaxSpeed
	end
end

and another one to manages those values:

while wait() do
	local car = script.Parent
	local seat = script.Parent.Seat.Value
	local speed = car.Speed.Value
	local angle = car.Angle.Value
	script.Parent:FindFirstChild("FR").HingeConstraint.AngularVelocity = speed*seat.Throttle*-1
	script.Parent:FindFirstChild("RR").HingeConstraint.AngularVelocity = speed*seat.Throttle*-1
	script.Parent:FindFirstChild("FL").HingeConstraint.AngularVelocity = speed*seat.Throttle
	script.Parent:FindFirstChild("RL").HingeConstraint.AngularVelocity = speed*seat.Throttle
	script.Parent:FindFirstChild("Chassis").HingeConstraint.TargetAngle = angle*seat.Steer
end

I am wondering why the motors are so delayed in functioning... On play solo, they work just fine, but on a test server, they are delayed by around 0.5 of a second.

Help would be much appreciated. Thanks in advance!

1 answer

If this works on solo well but on a test server not as much you could be a victim of latency.

Ping and latency (same thing) are the milliseconds it takes to travel from Server:Client. If I'm not mistaken it's virtually reproduced even in ROBLOX Test servers. There are a multitudes of ways you could avoid this, to some limits. One of these would be to use a local script, which, as you can imagine, can lead to security issues but typically, are fine for most players.

This discussion is preserved as it was. New answers, comments, and votes are closed.