§ How to · with Forge AI

How to make a Roblox vehicle system (with AI)

By Sametcan Tasgiran, Founder & Developer·Published ·Updated

A Roblox vehicle system needs five pieces: VehicleSeat with throttle/steer, body parts welded to the seat, exit handling, physics-tuned suspension, and collision damage. Forge AI generates all five in 1m 04s.

5 files · 180 lines · 1m 04s · 1 credit. Server-driven, exploit-resistant.

VehicleSeat-based driving

Standard Roblox VehicleSeat. Throttle (W/S), steer (A/D), brake (Space). Configurable max speed, acceleration, turn rate.

Welded body

Car body, wheels, lights, all WeldConstraint-joined to the VehicleSeat. Sit on the seat → you control the car. Exit via Roblox default jump.

Physics-tuned suspension

Wheels use Cylinder constraints with damping for realistic bounce. Configurable stiffness — arcade feel vs sim feel.

Collision damage

High-speed impacts apply damage to the driver. Optional damage to the car itself (tracked HP, smoke when low). Optional fire on destruction.

Multi-seat support

Driver seat + passenger seats. Passengers ride with the car, can exit independently. No throttle for passengers.

Engine sound

Sound pitch scales with throttle. Engine start/stop on enter/exit. Crash sound on impact. All configurable per vehicle.

Files Forge AI ships for this prompt

5 files · 180 lines · 1m 04s · 1 credit

ServerScriptService/VehicleServer.lua

Damage on impact, exit handling, sync state

58 lines

ReplicatedStorage/Modules/VehicleConfig.lua

Per-vehicle stats (speed, accel, HP, sound IDs)

42 lines

ReplicatedStorage/Remotes/VehicleHonk

Honk button → all nearby clients

instance

StarterPlayer/StarterPlayerScripts/VehicleClient.lua

Engine sound pitch, HUD updates

42 lines

StarterGui/VehicleHUD.lua

Speedometer + HP gauge + exit hint

38 lines

Sample output: ServerScriptService/VehicleServer.lua

--!strict
-- ServerScriptService/VehicleServer.lua  (Forge AI · excerpt)
local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VehicleConfig = require(ReplicatedStorage.Modules.VehicleConfig)

local IMPACT_THRESHOLD = 50  -- studs/sec speed
local IMPACT_DAMAGE_PER_STUD = 0.8

local function onVehicle(vehicle: Model)
    local seat = vehicle:FindFirstChildOfClass("VehicleSeat") :: VehicleSeat
    if not seat then return end
    local config = VehicleConfig[vehicle:GetAttribute("VehicleType") or "default"] or VehicleConfig.default
    seat.MaxSpeed = config.maxSpeed
    seat.Torque = config.torque
    seat.TurnSpeed = config.turnSpeed

    -- Track last velocity for impact detection
    local lastSpeed = 0

    -- Damage on high-speed collision
    for _, part in ipairs(vehicle:GetDescendants()) do
        if part:IsA("BasePart") then
            part.Touched:Connect(function(hit)
                local driverChar = seat.Occupant and seat.Occupant.Parent
                if not driverChar or not hit.Parent:FindFirstChildOfClass("Humanoid") or hit.Parent == driverChar then return end
                if lastSpeed > IMPACT_THRESHOLD then
                    local victimHum = hit.Parent:FindFirstChildOfClass("Humanoid") :: Humanoid
                    victimHum:TakeDamage((lastSpeed - IMPACT_THRESHOLD) * IMPACT_DAMAGE_PER_STUD)
                end
            end)
        end
    end

    -- Speed update loop
    task.spawn(function()
        while vehicle.Parent do
            task.wait(0.1)
            local root = seat.AssemblyLinearVelocity
            lastSpeed = math.sqrt(root.X^2 + root.Z^2)
        end
    end)
end

for _, v in ipairs(CollectionService:GetTagged("Vehicle")) do onVehicle(v) end
CollectionService:GetInstanceAddedSignal("Vehicle"):Connect(onVehicle)

Building a Roblox vehicle system

Vehicle systems are where Roblox's physics engine either shines or breaks. The native VehicleSeat handles 90% of the work — the trick is wiring it correctly and exposing the right config. Forge AI ships a vehicle template that works out of the box and tunes cleanly.

The Forge AI vehicle prompt produces a 5-file system in 1m 04s. VehicleConfig.lua is the data layer — per-vehicle stats like maxSpeed, torque, turnSpeed, HP, and sound IDs. VehicleServer.lua reads the config when a vehicle is tagged and applies the stats to the VehicleSeat. Multiple vehicle types (sedan, truck, sports car) coexist in the same place.

Welded body construction is the structural pattern. Wheels, body, lights, doors — all WeldConstraint-joined to a root part with the VehicleSeat. Sitting on the seat takes control; jumping off exits. No custom enter/exit script needed because VehicleSeat handles both natively.

Collision damage is the gameplay layer. A car going 60 studs/sec into a player applies damage proportional to the impact speed. Going 5 studs/sec applies nothing (gentle bump). The threshold and damage scaling are configurable. The check is exploit-resistant because it reads the server's view of velocity, not the client's claimed speed.

Suspension tuning is where arcade vs sim diverges. Forge defaults to arcade feel — high stiffness, low damping, responsive turns. Tweaking the Cylinder constraint stiffness on the wheels turns the same car into a sim experience. Forge can generate either preset on a follow-up prompt, or you tune the constants directly.

See more on the Luau generator, the game builder, or browse the full blog.

Frequently asked

How do I add a new vehicle type?+

Add an entry to VehicleConfig.lua: maxSpeed, torque, turnSpeed, HP, sound IDs. Tag the vehicle Model with 'Vehicle' via CollectionService. VehicleServer picks it up automatically.

Can passengers be added?+

Yes. Add additional Seat (not VehicleSeat) instances to the body, welded to the same root. Passengers sit but cannot drive. Forge can generate multi-seat vehicles on follow-up prompt.

How is the driver protected from exploits?+

The VehicleSeat itself is server-replicated — only the seated player's input affects throttle/steer. The actual movement physics run server-side via the VehicleSeat constraint. Exploiters can move their character but not write velocity to the car.

What about flying or boat vehicles?+

VehicleSeat is land-only. For flying, replace VehicleSeat with a regular Seat plus a custom BodyVelocity/BodyAngularVelocity setup. For boats, the same pattern with water-buoyancy. Forge has separate templates for both.

Does collision damage work with non-player obstacles?+

Yes. The damage check is triggered on Touched with any non-driver part. Walls, trees, other cars — all trigger damage based on impact speed. Configurable threshold per vehicle.

Related Forge AI prompts