Help with constraints

Hii I am having trouble with constraints; could you anyone check the file and help me pls?


Here’s a repro file;
car.rbxm (654.7 KB)

Code;

Code
local Chassis = script.Parent.Parent.Chassis
local Wheels = Chassis.Wheels
local MainPart = Chassis.mainpart
local Body = script.Parent.Parent.Body
local Configurations = require(script.Parent.Configurations)
local Physics = game:GetService("PhysicsService")
Physics:CreateCollisionGroup("Chassis")
Physics:CollisionGroupSetCollidable("Chassis","Chassis",false)

MainPart.Anchored = true

for i,v in pairs(Body.Car:GetDescendants()) do
	if (v:IsA('BasePart') or v:IsA("MeshPart")) then
		local WeldConstraint = Instance.new("WeldConstraint")
		WeldConstraint.Part0 = MainPart
		WeldConstraint.Part1 = v
		WeldConstraint.Parent = v 
		WeldConstraint.Name = "BodyToCar Weld"
		v.CanCollide = false
		v.Massless = true
	end
end

for i,v in pairs(Body.Wheels:GetChildren()) do
	if (Wheels:FindFirstChild(v.Name)) then
		local RealWheel = Wheels:FindFirstChild(v.Name)
		RealWheel.Transparency = 1
		for a,b in pairs(v:GetDescendants()) do
			if (b:IsA("BasePart")) then
				local Weld = Instance.new("WeldConstraint")
				Weld.Parent = RealWheel
				Weld.Part0 = RealWheel
				Weld.Part1 = b
				b.CanCollide = false;
			end
		end
	end
end

for i,v in pairs(script.Parent:GetDescendants()) do
	if (v:IsA("BasePart")) then
		Physics:SetPartCollisionGroup(v,"Chassis")
	end
end


local TotalCarMass = 0

for i,v in pairs(script.Parent.Parent:GetDescendants()) do
	if (v:IsA("BasePart")) then
		if not (v.Massless) then
			TotalCarMass += v:GetMass()
		end
	end
end
TotalCarMass = TotalCarMass * workspace.Gravity

Configurations.SpringConstraint.MaxForce = math.huge
Configurations.SpringConstraint.Stiffness = TotalCarMass

for i,v in pairs(Wheels:GetChildren()) do
	local Offset = MainPart.CFrame:PointToObjectSpace(v.Position)
	if (Offset.X > 0) then  -- right
		print(v.Name,"Right")
		local Wheel = v
		local FWheelFolder = Instance.new("Folder")
		FWheelFolder.Name = v.Name:upper()
		FWheelFolder.Parent = Chassis		
		local Suspensionpart = Instance.new("Part")
		Suspensionpart.Size = Vector3.new(.5,.5,.5)
		Suspensionpart.CFrame = (Wheel.CFrame * CFrame.new(-1,2,0)) * CFrame.new(Suspensionpart.Size.X/2,0,0)
		Suspensionpart.Parent = FWheelFolder
		Suspensionpart.Name = 'Suspensionpart'
		Suspensionpart.CanCollide = false;
		local VehicleStructurePart = Instance.new("Part")
		VehicleStructurePart.Parent = FWheelFolder
		VehicleStructurePart.Name = 'VehicleStructurePart'
		VehicleStructurePart.CFrame = Suspensionpart.CFrame * CFrame.new(0,1.5,0)
		VehicleStructurePart.Size = Vector3.new(.5,.5,.5)
		VehicleStructurePart.CanCollide = false;
		local WeldToCar = Instance.new("WeldConstraint")
		WeldToCar.Parent = MainPart
		WeldToCar.Part0 = MainPart
		WeldToCar.Part1 = VehicleStructurePart

		local AttachmentVehicleStructurePart = Instance.new("Attachment")
		AttachmentVehicleStructurePart.Parent = VehicleStructurePart
		AttachmentVehicleStructurePart.Name = 'AttachmentVehicleStructurePart'
		AttachmentVehicleStructurePart.Orientation = Vector3.new(0,0,90)

		local AttachmentSuspensionpart = Instance.new("Attachment")
		AttachmentSuspensionpart.Parent = Suspensionpart
		AttachmentSuspensionpart.Name = 'AttachmentSuspensionpart'
		AttachmentSuspensionpart.Orientation = Vector3.new(0,0,90)

		local Spring = Instance.new("SpringConstraint")
		Spring.Name = 'Spring Suspension'
		Spring.Attachment0 = AttachmentVehicleStructurePart
		Spring.Attachment1 = AttachmentSuspensionpart
		Spring.Parent = FWheelFolder
		for i,v in pairs(Configurations.SpringConstraint) do
			Spring[i] = v;
		end

		local Prismatic = Instance.new("PrismaticConstraint")
		Prismatic.Name = 'Prismatic Suspension'
		Prismatic.Attachment0 = AttachmentVehicleStructurePart
		Prismatic.Attachment1 = AttachmentSuspensionpart
		Prismatic.Parent = FWheelFolder
		for i,v in pairs(Configurations.PrismaticConstraint.Right) do
			Prismatic[i] = v;
		end

		local MotorAttachment = Instance.new("Attachment")
		MotorAttachment.Parent = Suspensionpart
		MotorAttachment.Name = 'MotorAttachment'

		local WheelAttachment = Instance.new("Attachment")
		WheelAttachment.Parent = Wheel
		WheelAttachment.Name = 'MotorAttachment'

		local Motor = Instance.new("HingeConstraint")
		Motor.Attachment0 = MotorAttachment
		Motor.Attachment1 = WheelAttachment
		Motor.Parent = FWheelFolder
		Motor.Name = "Motor"
	else -- left
		local Wheel = v
		local FWheelFolder = Instance.new("Folder")
		FWheelFolder.Name = v.Name:upper()
		FWheelFolder.Parent = Chassis		
		local Suspensionpart = Instance.new("Part")
		Suspensionpart.Size = Vector3.new(.5,.5,.5)
		Suspensionpart.CFrame = (Wheel.CFrame * CFrame.new(1,2,0)) * CFrame.new(-Suspensionpart.Size.X/2,0,0)
		Suspensionpart.Parent = FWheelFolder
		Suspensionpart.Name = 'Suspensionpart'
		Suspensionpart.CanCollide = false;
		local VehicleStructurePart = Instance.new("Part")
		VehicleStructurePart.Parent = FWheelFolder
		VehicleStructurePart.Name = 'VehicleStructurePart'
		VehicleStructurePart.CFrame = Suspensionpart.CFrame * CFrame.new(0,1.5,0)
		VehicleStructurePart.Size = Vector3.new(.5,.5,.5)
		VehicleStructurePart.CanCollide = false;
		local WeldToCar = Instance.new("WeldConstraint")
		WeldToCar.Parent = MainPart
		WeldToCar.Part0 = MainPart
		WeldToCar.Part1 = VehicleStructurePart

		local AttachmentVehicleStructurePart = Instance.new("Attachment")
		AttachmentVehicleStructurePart.Parent = VehicleStructurePart
		AttachmentVehicleStructurePart.Name = 'AttachmentVehicleStructurePart'
		AttachmentVehicleStructurePart.Orientation = Vector3.new(0,0,90)

		local AttachmentSuspensionpart = Instance.new("Attachment")
		AttachmentSuspensionpart.Parent = Suspensionpart
		AttachmentSuspensionpart.Name = 'AttachmentSuspensionpart'
		AttachmentSuspensionpart.Orientation = Vector3.new(0,0,90)

		local Spring = Instance.new("SpringConstraint")
		Spring.Name = 'Spring Suspension'
		Spring.Attachment0 = AttachmentVehicleStructurePart
		Spring.Attachment1 = AttachmentSuspensionpart
		Spring.Parent = FWheelFolder
		for i,v in pairs(Configurations.SpringConstraint) do
			Spring[i] = v;
		end

		local Prismatic = Instance.new("PrismaticConstraint")
		Prismatic.Name = 'Prismatic Suspension'
		Prismatic.Attachment0 = AttachmentVehicleStructurePart
		Prismatic.Attachment1 = AttachmentSuspensionpart
		Prismatic.Parent = FWheelFolder
		for i,v in pairs(Configurations.PrismaticConstraint.Left) do
			Prismatic[i] = v;
		end

		local MotorAttachment = Instance.new("Attachment")
		MotorAttachment.Parent = Suspensionpart
		MotorAttachment.Name = 'MotorAttachment'

		local WheelAttachment = Instance.new("Attachment")
		WheelAttachment.Parent = Wheel
		WheelAttachment.Name = 'MotorAttachment'

		local Motor = Instance.new("HingeConstraint")
		Motor.Attachment0 = MotorAttachment
		Motor.Attachment1 = WheelAttachment
		Motor.Parent = FWheelFolder
		Motor.Name = "Motor"
	end
end


MainPart.Anchored = false

Thanks, help appreciated :smiley:

Hiiii can someone help me out?