Run it
Copy the script and paste it into your executor.
Players = :()
RunService = :()
player = Players.LocalPlayer
CONFIG = {
TargetSpeed = ,
RoadName = ,
RoadSize = .(, , ),
RoadPosition = .(, , ),
SpawnPosition = .(, , ),
SpawnYaw = ,
MinYBeforeReset = ,
MaxZBeforeReset = ,
CenterX = ,
CenteringGain = ,
MaxSideVelocity = ,
TeleportCooldown = ,
OrientationResponsiveness = ,
OrientationMaxTorque = ,
}
currentVehicle: Model? =
currentMainPart: BasePart? =
isResetting =
heartbeatConnection: RBXScriptConnection? =
(): Part
road = :(CONFIG.RoadName)
road road:()
road.Size = CONFIG.RoadSize
road.Position = CONFIG.RoadPosition
road
road road:()
road:()
newRoad = .()
newRoad.Name = CONFIG.RoadName
newRoad.Size = CONFIG.RoadSize
newRoad.Position = CONFIG.RoadPosition
newRoad.Anchored =
newRoad.CanCollide =
newRoad.CanTouch =
newRoad.CanQuery =
newRoad.Transparency =
newRoad.Material = .Material.SmoothPlastic
newRoad.CastShadow =
newRoad.Locked =
newRoad.Parent =
newRoad
()
(): Model?
player.Character
(character: Model?): Humanoid?
character
character:()
(): (Model?, BasePart?)
character = ()
humanoid = (character)
character humanoid
,
seat = humanoid.SeatPart
seat seat:()
,
vehicle = seat:()
vehicle
,
mainPart = vehicle.PrimaryPart seat
mainPart mainPart:()
,
vehicle, mainPart
(part: BasePart?)
part
oldAttachment = part:()
oldAttachment
oldAttachment:()
oldAlign = part:()
oldAlign
oldAlign:()
(part: BasePart)
(part)
attachment = .()
attachment.Name =
attachment.Parent = part
align = .()
align.Name =
align.Mode = .OrientationAlignmentMode.OneAttachment
align.Attachment0 = attachment
align.RigidityEnabled =
align.ReactionTorqueEnabled =
align.Responsiveness = CONFIG.OrientationResponsiveness
align.MaxTorque = CONFIG.OrientationMaxTorque
align.CFrame = .(.zero, .(, , ), .(, , ))
align.Parent = part
(vehicle: Model, mainPart: BasePart)
currentMainPart == mainPart currentVehicle == vehicle
currentMainPart
(currentMainPart)
currentVehicle = vehicle
currentMainPart = mainPart
(mainPart)
()
currentMainPart
(currentMainPart)
currentVehicle =
currentMainPart =
(vehicle: Model?, mainPart: BasePart?)
isResetting mainPart
isResetting =
mainPart.AssemblyLinearVelocity = .zero
mainPart.AssemblyAngularVelocity = .zero
spawnCF = .(CONFIG.SpawnPosition) * .(, .(CONFIG.SpawnYaw), )
vehicle
vehicle:(spawnCF)
mainPart.CFrame = spawnCF
.(CONFIG.TeleportCooldown, ()
isResetting =
)
()
isResetting
vehicle, mainPart = ()
vehicle mainPart
()
(vehicle, mainPart)
pos = mainPart.Position
pos.Y < CONFIG.MinYBeforeReset pos.Z > CONFIG.MaxZBeforeReset
(vehicle, mainPart)
mainPart.AssemblyAngularVelocity = .zero
lateralError = CONFIG.CenterX - pos.X
sideVelocity = .(
lateralError * CONFIG.CenteringGain,
-CONFIG.MaxSideVelocity,
CONFIG.MaxSideVelocity
)
currentYVelocity = mainPart.AssemblyLinearVelocity.Y
mainPart.AssemblyLinearVelocity = .(
sideVelocity,
currentYVelocity,
CONFIG.TargetSpeed
)
.AutoDriveConnection
.AutoDriveConnection:()
.AutoDriveConnection =
heartbeatConnection = RunService.Heartbeat:(stepVehicle)
.AutoDriveConnection = heartbeatConnection
player.CharacterRemoving:(()
()
)You must board the vehicle before using it.