Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come my remote controlled vehicle is delayed?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
6 years ago

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.

Ad

Answer this question