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

i made a scripted car and i want to make a set speed for it. it is wrong, can someone help me?

Asked by 6 years ago
local seat = script.Parent
local LeftDrive = seat.Parent.FrontAxle.LeftDrive
local RightDrive = seat.Parent.FrontAxle2.RightDrive
local SteerHinge = seat.Parent.FrontAxle.SteerHinge
local SteerHinge2 = seat.Parent.FrontAxle2.SteerHinge2
local SteerAngle = 30
local MaxSpeed = 160
local Reverse = 40
local Foward = 160

local function OnChanged(property)
    if property == "Steer" then
        SteerHinge.TargetAngle = SteerAngle * seat.Steer
        SteerHinge2.TargetAngle = SteerAngle * seat.Steer
    end
    if property == "Throttle" then
        LeftDrive.AngularVelocity = MaxSpeed * seat.Throttle
        RightDrive.AngularVelocity = MaxSpeed * seat.Throttle
    end
end

seat.Changed:connect(OnChanged)

if seat.ThrottleFloat == -1 then
    MaxSpeed = Reverse
end

if seat.ThrottleFloat == 1 then
    MaxSpeed = Foward
end

In this script, i want to make a set speed for the car when it moves backward or foward. The above script didnt work, pls fix it for me! Thx !

0
You'll probably need to be a bit more specific that "it doesn't work". fredfishy 833 — 6y
0
the speed limit doesnt work. i forgot to say it FriendlyKevinPotato -8 — 6y

Answer this question