local g=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local V=game.Workspace.CurrentCamera local j=game.Players.LocalPlayer local O=j.Character local f=O.HumanoidRootPart local n=(script:WaitForChild("\067\097\114")).Value local c=n:WaitForChild("\067\111\110\102\105\103\117\114\097\116\105\111\110\115")local R=require(n.CarScript.RaycastModule)local o=Enum.CameraType.Follow local p=Vector2.new()local Q=n:WaitForChild("\068\114\105\118\101\083\101\097\116")Q.Changed:Connect(function(g)if g=="\084\104\114\111\116\116\108\101"then p=Vector2.new(p.X,Q.Throttle)end if g=="\083\116\101\101\114"then p=Vector2.new(Q.Steer,p.Y)end end)local C=0 local d=0 local E=0 for g,V in pairs(n:GetChildren())do if V:IsA("\066\097\115\101\080\097\114\116")then E=E+V:GetMass()*196.2 end end C=E*c.Suspension.Value d=C/c.Bounce.Value local P=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121",n.Chassis)P.velocity=Vector3.new(0,0,0)P.maxForce=Vector3.new(0,0,0)local q=Instance.new("\066\111\100\121\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121",n.Chassis)q.angularvelocity=Vector3.new(0,0,0)q.maxTorque=Vector3.new(0,0,0)local H=0 local function h(g)local V=g:FindFirstChild("\066\111\100\121\084\104\114\117\115\116")if not V then V=Instance.new("\066\111\100\121\084\104\114\117\115\116",g)end local j,O=R.new(g.Position,g.CFrame:vectorToWorldSpace(Vector3.new(0,-1,0))*c.Height.Value)local f=(O-g.Position).magnitude if j and j.CanCollide then V.force=Vector3.new(0,(c.Height.Value-f)^2*(C/c.Height.Value^2),0)local j=(g.CFrame:toObjectSpace(CFrame.new(g.Velocity+g.Position))).p*d V.force=V.force-Vector3.new(0,j.Y,0)else V.force=Vector3.new(0,0,0)end local o=g:FindFirstChild("\087\104\101\101\108\087\101\108\100")if o then o.C0=CFrame.new(0,-math.min(f,c.Height.Value*.8)+o.Part1.Size.Y/2,0)local V=n.Chassis.CFrame:inverse()*g.CFrame local j=n.Chassis.CFrame:vectorToObjectSpace(n.Chassis.Velocity)if V.Z<0 then local g=1 if j.Z>0 then g=-1 end o.C0=o.C0*CFrame.Angles(0,(n.Chassis.RotVelocity.Y/2)*g,0)end o.C0=o.C0*CFrame.Angles(H,0,0)end end
--Scripted by DermonDarble
local userInputService = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local humanoidRootPart = character.HumanoidRootPart
local car = script:WaitForChild("Car").Value
local stats = car:WaitForChild("Configurations")
local Raycast = require(car.CarScript.RaycastModule)

local cameraType = Enum.CameraType.Follow

local movement = Vector2.new()

local seat = car:WaitForChild("DriveSeat")

seat.Changed:Connect(function(property)
	if property == "Throttle" then
		movement = Vector2.new(movement.X, seat.Throttle)
	end
	if property == "Steer" then
		movement = Vector2.new(seat.Steer, movement.Y)
	end
end)

local force = 0
local damping = 0

local mass = 0

for i, v in pairs(car:GetChildren()) do
	if v:IsA("BasePart") then
		mass = mass + (v:GetMass() * 196.2)
	end
end

force = mass * stats.Suspension.Value
damping = force / stats.Bounce.Value

local bodyVelocity = Instance.new("BodyVelocity", car.Chassis)
bodyVelocity.velocity = Vector3.new(0, 0, 0)
bodyVelocity.maxForce = Vector3.new(0, 0, 0)

local bodyAngularVelocity = Instance.new("BodyAngularVelocity", car.Chassis)
bodyAngularVelocity.angularvelocity = Vector3.new(0, 0, 0)
bodyAngularVelocity.maxTorque = Vector3.new(0, 0, 0)

local rotation = 0

local function UpdateThruster(thruster)
	--Make sure we have a bodythrust to move the wheel
	local bodyThrust = thruster:FindFirstChild("BodyThrust")
	if not bodyThrust then
		bodyThrust = Instance.new("BodyThrust", thruster)
	end
	--Do some raycasting to get the height of the wheel
	local hit, position =
		Raycast.new(thruster.Position, thruster.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * stats.Height.Value)
	local thrusterHeight = (position - thruster.Position).magnitude
	if hit and hit.CanCollide then
		--If we're on the ground, apply some forces to push the wheel up
		bodyThrust.force =
			Vector3.new(0, ((stats.Height.Value - thrusterHeight) ^ 2) * (force / stats.Height.Value ^ 2), 0)
		local thrusterDamping = thruster.CFrame:toObjectSpace(CFrame.new(thruster.Velocity + thruster.Position)).p
			* damping
		bodyThrust.force = bodyThrust.force - Vector3.new(0, thrusterDamping.Y, 0)
	else
		bodyThrust.force = Vector3.new(0, 0, 0)
	end

	--Wheels
	local wheelWeld = thruster:FindFirstChild("WheelWeld")
	if wheelWeld then
		wheelWeld.C0 =
			CFrame.new(0, -math.min(thrusterHeight, stats.Height.Value * 0.8) + (wheelWeld.Part1.Size.Y / 2), 0)
		-- Wheel turning
		local offset = car.Chassis.CFrame:inverse() * thruster.CFrame
		local speed = car.Chassis.CFrame:vectorToObjectSpace(car.Chassis.Velocity)
		if offset.Z < 0 then
			local direction = 1
			if speed.Z > 0 then
				direction = -1
			end
			wheelWeld.C0 = wheelWeld.C0 * CFrame.Angles(0, (car.Chassis.RotVelocity.Y / 2) * direction, 0)
		end
		wheelWeld.C0 = wheelWeld.C0 * CFrame.Angles(rotation, 0, 0)
	end
end
