local i=script.Parent local F=game:GetService("\082\117\110\083\101\114\118\105\099\101")local r=i.Wheels local G=i.Body.VehicleSeat local h=G.ATSVariables local A={"\087\104\101\101\108\115"}function WeldPair(i,F)local r=Instance.new("\087\101\108\100",i)r.Part0=i r.Part1=F r.C1=F.CFrame:toObjectSpace(i.CFrame)end function WeldAll(i,F)for F,r in pairs(A)do if i.Name==r then return end end if i:IsA("\066\097\115\101\080\097\114\116")then WeldPair(F,i)end for i,r in pairs(i:GetChildren())do WeldAll(r,F)end end function UnanchorAll(i)if i:IsA("\066\097\115\101\080\097\114\116")then i.Anchored=false end for i,F in pairs(i:GetChildren())do UnanchorAll(F)end end function Joint(i,F,r,G,h)local A=Instance.new(h,i)A.Part0=i A.Part1=F A.C0=r A.C1=G return A end function CreateWheelPart()local i=Instance.new("\080\097\114\116")i.FormFactor=Enum.FormFactor.Custom i.Transparency=1 i.Anchored=true i.CanCollide=false i.TopSurface=Enum.SurfaceType.Unjoinable i.BottomSurface=Enum.SurfaceType.Unjoinable i.LeftSurface=Enum.SurfaceType.Unjoinable i.RightSurface=Enum.SurfaceType.Unjoinable i.FrontSurface=Enum.SurfaceType.Unjoinable i.BackSurface=Enum.SurfaceType.Unjoinable return i end for i,F in pairs(r:GetChildren())do if F:IsA("\066\097\115\101\080\097\114\116")then local i=F.Size.x local G=Instance.new("\077\111\100\101\108",r)G.Name=F.Name F.Parent=G F.Name="\087\104\101\101\108"for i,r in pairs(F:GetChildren())do if r:IsA("\066\097\115\101\080\097\114\116")then r.Parent=G WeldPair(F,r)r.CanCollide=false end end if F:FindFirstChild("\083\116\101\101\114")then local r=CreateWheelPart()r.Name="\083\116\101\101\114"r.Size=Vector3.new(i,1,.6)r.CFrame=F.CFrame r.Parent=G end local A=CreateWheelPart()A.Name="\083\117\115\112\101\110\115\105\111\110"A.Size=Vector3.new(.8,1,i)A.CFrame=F.CFrame*CFrame.new(-1,0,0)A.Parent=G local X=Instance.new("\066\111\100\121\071\121\114\111")X.Name="\066\071"X.D=h.SuspensionDampening.Value X.P=h.SuspensionPower.Value X.maxTorque=Vector3.new()X.Parent=A local C=CreateWheelPart()C.Name="\066\111\100\121\072\105\110\103\101"C.Size=Vector3.new(.8,1,i)C.CFrame=F.CFrame*CFrame.new(1,0,0)C.Parent=G if F:FindFirstChild("\080\111\119\101\114\101\100")then local i=Instance.new("\066\111\100\121\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121")i.Name="\066\065\086"i.angularvelocity=Vector3.new()i.maxTorque=Vector3.new(60000,0,60000)i.P=300 i.Parent=F end end end for i,F in pairs(r:GetChildren())do if F:FindFirstChild("\087\104\101\101\108")and F:FindFirstChild("\083\117\115\112\101\110\115\105\111\110")then local i=F:FindFirstChild("\083\116\101\101\114")~=nil if F:FindFirstChild("\077\101\115\104")then WeldAll(F.Mesh,F.Wheel)end if i then Joint(F.Wheel,F.Steer,CFrame.Angles(math.pi/2,0,0),F.Steer.CFrame:toObjectSpace(F.Wheel.CFrame)*CFrame.Angles(math.pi/2,0,0),"\082\111\116\097\116\101")local i=Joint(F.Steer,F.Suspension,CFrame.Angles(math.pi,0,0),F.Suspension.CFrame:toObjectSpace(F.Steer.CFrame)*CFrame.Angles(math.pi,0,0),"\077\111\116\111\114")i.MaxVelocity=.03 else Joint(F.Wheel,F.Suspension,CFrame.Angles(math.pi/2,0,0),F.Suspension.CFrame:toObjectSpace(F.Wheel.CFrame)*CFrame.Angles(math.pi/2,0,0),"\082\111\116\097\116\101")end Joint(F.Suspension,F.BodyHinge,CFrame.new(Vector3.new(2,0,0))*CFrame.Angles(math.pi/2,0,0),(F.BodyHinge.CFrame:toObjectSpace(F.Suspension.CFrame)*CFrame.new(Vector3.new(2,0,0)))*CFrame.Angles(math.pi/2,0,0),"\082\111\116\097\116\101")Joint(F.BodyHinge,G,CFrame.new(),G.CFrame:toObjectSpace(F.BodyHinge.CFrame),"\087\101\108\100")else print("\073\110\118\097\108\105\100 \119\104\101\101\108\058 \077\105\115\115\105\110\103 \087\104\101\101\108 \111\114 \083\117\115\112\101\110\115\105\111\110 \112\097\114\116\033")end end WeldAll(i,G)wait(.5)UnanchorAll(i)function UpdateWheels()for i,F in pairs(r:GetChildren())do if F:FindFirstChild("\083\117\115\112\101\110\115\105\111\110")then F.Suspension.BG.cframe=G.CFrame*CFrame.Angles(-math.pi/2,-math.rad(h.SuspensionAngle.Value),0)end end end UpdateWheels()for i,F in pairs(r:GetChildren())do if F:FindFirstChild("\083\117\115\112\101\110\115\105\111\110")then F.Suspension.BG.maxTorque=Vector3.new(0,1,0)end end F.Heartbeat:connect(UpdateWheels)
-- ATS 1.2.2
--------------------------------------------------------------------------------------------------
local P = script.Parent
local Run = game:GetService("RunService")
local wheels = P.Wheels
local seat = P.Body.VehicleSeat
local vars = seat.ATSVariables

local exclude = { "Wheels" }

function WeldPair(x, y)
	local weld = Instance.new("Weld", x)
	weld.Part0 = x
	weld.Part1 = y
	weld.C1 = y.CFrame:toObjectSpace(x.CFrame)
end

function WeldAll(model, main) -- model can be anything
	for i, v in pairs(exclude) do
		if model.Name == v then
			return
		end
	end
	if model:IsA("BasePart") then
		WeldPair(main, model)
	end
	for _, v in pairs(model:GetChildren()) do
		WeldAll(v, main)
	end
end

function UnanchorAll(model) -- model can be anything
	if model:IsA("BasePart") then
		model.Anchored = false
	end
	for _, v in pairs(model:GetChildren()) do
		UnanchorAll(v)
	end
end

function Joint(x, y, c0, c1, type)
	local W = Instance.new(type, x)
	W.Part0 = x
	W.Part1 = y
	W.C0 = c0
	W.C1 = c1
	return W
end

function CreateWheelPart()
	local p = Instance.new("Part")
	p.FormFactor = Enum.FormFactor.Custom
	p.Transparency = 1
	p.Anchored = true
	p.CanCollide = false
	p.TopSurface = Enum.SurfaceType.Unjoinable
	p.BottomSurface = Enum.SurfaceType.Unjoinable
	p.LeftSurface = Enum.SurfaceType.Unjoinable
	p.RightSurface = Enum.SurfaceType.Unjoinable
	p.FrontSurface = Enum.SurfaceType.Unjoinable
	p.BackSurface = Enum.SurfaceType.Unjoinable
	return p
end

for i, v in pairs(wheels:GetChildren()) do
	if v:IsA("BasePart") then
		local diameter = v.Size.x
		local M = Instance.new("Model", wheels)
		M.Name = v.Name
		v.Parent = M
		v.Name = "Wheel"
		for j, w in pairs(v:GetChildren()) do
			if w:IsA("BasePart") then
				w.Parent = M
				WeldPair(v, w)
				w.CanCollide = false
			end
		end
		if v:FindFirstChild("Steer") then
			local A = CreateWheelPart()
			A.Name = "Steer"
			A.Size = Vector3.new(diameter, 1, 0.6)
			A.CFrame = v.CFrame
			A.Parent = M
		end
		local B = CreateWheelPart()
		B.Name = "Suspension"
		B.Size = Vector3.new(0.8, 1, diameter)
		B.CFrame = v.CFrame * CFrame.new(-1, 0, 0)
		B.Parent = M
		local BB = Instance.new("BodyGyro")
		BB.Name = "BG"
		BB.D = vars.SuspensionDampening.Value
		BB.P = vars.SuspensionPower.Value
		BB.maxTorque = Vector3.new()
		BB.Parent = B
		local C = CreateWheelPart()
		C.Name = "BodyHinge"
		C.Size = Vector3.new(0.8, 1, diameter)
		C.CFrame = v.CFrame * CFrame.new(1, 0, 0)
		C.Parent = M
		if v:FindFirstChild("Powered") then
			local CC = Instance.new("BodyAngularVelocity")
			CC.Name = "BAV"
			CC.angularvelocity = Vector3.new()
			CC.maxTorque = Vector3.new(60000, 0, 60000)
			CC.P = 300
			CC.Parent = v
		end
	end
end

for i, v in pairs(wheels:GetChildren()) do
	if (v:FindFirstChild("Wheel")) and (v:FindFirstChild("Suspension")) then
		local isSteeringWheel = (v:FindFirstChild("Steer") ~= nil)
		if v:FindFirstChild("Mesh") then
			WeldAll(v.Mesh, v.Wheel)
		end
		if isSteeringWheel then
			Joint(
				v.Wheel,
				v.Steer,
				CFrame.Angles(math.pi / 2, 0, 0),
				v.Steer.CFrame:toObjectSpace(v.Wheel.CFrame) * CFrame.Angles(math.pi / 2, 0, 0),
				"Rotate"
			)
			local M = Joint(
				v.Steer,
				v.Suspension,
				CFrame.Angles(math.pi, 0, 0),
				v.Suspension.CFrame:toObjectSpace(v.Steer.CFrame) * CFrame.Angles(math.pi, 0, 0),
				"Motor"
			)
			M.MaxVelocity = 0.03
		else
			Joint(
				v.Wheel,
				v.Suspension,
				CFrame.Angles(math.pi / 2, 0, 0),
				v.Suspension.CFrame:toObjectSpace(v.Wheel.CFrame) * CFrame.Angles(math.pi / 2, 0, 0),
				"Rotate"
			)
		end
		Joint(
			v.Suspension,
			v.BodyHinge,
			CFrame.new(Vector3.new(2, 0, 0)) * CFrame.Angles(math.pi / 2, 0, 0),
			v.BodyHinge.CFrame:toObjectSpace(v.Suspension.CFrame)
				* CFrame.new(Vector3.new(2, 0, 0))
				* CFrame.Angles(math.pi / 2, 0, 0),
			"Rotate"
		)
		Joint(v.BodyHinge, seat, CFrame.new(), seat.CFrame:toObjectSpace(v.BodyHinge.CFrame), "Weld")
	else
		print("Invalid wheel: Missing Wheel or Suspension part!")
	end
end

WeldAll(P, seat)

wait(0.5)

UnanchorAll(P)

function UpdateWheels()
	for i, v in pairs(wheels:GetChildren()) do
		if v:FindFirstChild("Suspension") then
			v.Suspension.BG.cframe = seat.CFrame * CFrame.Angles(-math.pi / 2, -math.rad(vars.SuspensionAngle.Value), 0)
		end
	end
end

UpdateWheels()
for i, v in pairs(wheels:GetChildren()) do
	if v:FindFirstChild("Suspension") then
		v.Suspension.BG.maxTorque = Vector3.new(0, 1, 0)
	end
end

Run.Heartbeat:connect(UpdateWheels)
