RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Make a CFrame car driving system that moves model"
-- car driving system using CFrame local seat = script.Parent.VehicleSeat local carModel = script.Parent.Parent local speed = 30 local turnSpeed = 0.05 local function drive() while seat.Occupant do local throttle = seat.Throttle local steer = seat.Steer local carCFrame = carModel.PrimaryPart.CFrame -- Move forward or backward local moveDirection = carCFrame.LookVector * throttle * speed carModel:SetPrimaryPartCFrame(carCFrame + moveDirection) -- Turn left or right local turnCFrame = CFrame.Angles(0, steer * turnSpeed, 0) carModel:SetPrimaryPartCFrame(carCFrame * turnCFrame) wait() end end seat:GetPropertyChangedSignal("Occupant"):Connect(function() if seat.Occupant then drive() end end)