Car Wheels are weird moving. (Make it similar to dusty trip)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want make it car wheel only moving in Y axis Position.
    And make it wheels similar to dusty trip because wheels not need objects to hold it or make it easier for custom wheels to insert it.
  2. What is the issue? Include screenshots / videos if possible!
    I can’t create video for it but you can see it in file.
    Issue is my wheels moving weird and very fast due AlignPosition and AlignOrientation.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yea i look developer hub but i not found it. Because Soms peoples are bug fixed but not gived codes for bug.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Sorry for long script onder this line.

local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Body")
PhysicsService:RegisterCollisionGroup("Wheels")
PhysicsService:CollisionGroupSetCollidable("Body", "Wheels", false)

local Car = script.Parent
local Main = Car.Main
local MainSeat = Car.MainSeat
local Wheels = Car.Wheels
local Body = Car.Body

function ConnectWheelToHolder(Wheel: BasePart, Holder: BasePart)
	if Wheel:IsA("BasePart") and Holder:IsA("BasePart") then
		Holder.CollisionGroup = "Body"
		Wheel.CollisionGroup = "Wheels"
		local WheelAttachment
		local HolderAttachment
		if Wheel:FindFirstChild("WheelAttachment") then
			WheelAttachment = Wheel:FindFirstChild("WheelAttachment")
		else
			WheelAttachment = Instance.new("Attachment")
			WheelAttachment.Name = "WheelAttachment"
			WheelAttachment.Parent = Wheel
		end
		if Holder:FindFirstChild("HolderAttachment") then
			HolderAttachment = Holder:FindFirstChild("HolderAttachment")
		else
			HolderAttachment = Instance.new("Attachment")
			HolderAttachment.Name = "HolderAttachment"
			HolderAttachment.Parent = Holder
		end
		if not Wheel:FindFirstChild("AO") then
			local AO = Instance.new("AlignOrientation")
			AO.Name = "AO"
			AO.Mode = Enum.OrientationAlignmentMode.OneAttachment
			AO.RigidityEnabled = true
			AO.Attachment0 = WheelAttachment
			AO.Parent = Wheel
		end
		if not Wheel:FindFirstChild("AP") then
			local AP = Instance.new("AlignPosition")
			AP.Name = "AP"
			AP.Mode = Enum.PositionAlignmentMode.TwoAttachment
			AP.Attachment0 = WheelAttachment
			AP.Attachment1 = HolderAttachment
			AP.ForceLimitMode = Enum.ForceLimitMode.PerAxis
			AP.ForceRelativeTo = Enum.ActuatorRelativeTo.Attachment0
			AP.MaxAxesForce = Vector3.new(10000, 0, 10000)
			AP.Responsiveness = 100
			AP.Parent = Wheel
		end
		local SpringConstraint = Instance.new("SpringConstraint")
		SpringConstraint.Visible = true
		SpringConstraint.Attachment0 = HolderAttachment
		SpringConstraint.Attachment1 = WheelAttachment
		SpringConstraint.Damping = 10
		SpringConstraint.FreeLength = 7.5
		SpringConstraint.Stiffness = 1000
		SpringConstraint.LimitsEnabled = true
		local Distance = (Wheel.Position - Holder.Position).Magnitude
		SpringConstraint.MinLength = Distance
		SpringConstraint.MaxLength = Distance + 2
		SpringConstraint.Parent = Wheel
	else
		warn("Wheel or holder is not Basepart")
	end
end

for i, wheel in ipairs(Wheels:GetChildren()) do
	if wheel:IsA("Model") and wheel:FindFirstChild("Wheel") then
		if Wheels:FindFirstChild(wheel.Name.."Holder") then
			ConnectWheelToHolder(wheel:FindFirstChild("Wheel"), Wheels:FindFirstChild(wheel.Name.."Holder"))
		end
	end
end

for i, objects in ipairs(Car:GetDescendants()) do
	if objects:IsA("BasePart") then
		if objects.Parent.Name == "Wheels" or objects.Parent.Name == "Body" or objects.Parent.Parent.Name == "Body" then
			objects.CollisionGroup = "Body"
			local Weld = Instance.new("WeldConstraint")
			Weld.Part0 = Main
			Weld.Part1 = objects
			Weld.Parent = objects
		end
	end
end

Car_test.rbxl (78.1 KB)

1 Like

Come on! I’m wait so long.β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

1 Like

Hello, Here is my attempting on fixing the issue, if you have any questions or need help make sure you ask!

--|< Services >|--
local PhysicsService = game:GetService("PhysicsService");

--|< Collision Inits >|--
PhysicsService:RegisterCollisionGroup("Body");
PhysicsService:RegisterCollisionGroup("Wheels");
PhysicsService:CollisionGroupSetCollidable("Body", "Wheels", false);

--|< Variables >|--
local car = script.Parent;
local main = car:WaitForChild("Main");
local mainSeat = car:WaitForChild("MainSeat");
local wheels = car:WaitForChild("Wheels");
local body = car:WaitForChild("Body");
;
--|< Functions >|--
local function createAttachment(parent, name)
    local attachment = parent:FindFirstChild(name) or Instance.new("Attachment");
    attachment.Name = name;
    attachment.Parent = parent;
    return attachment
end

local function ConnectWheelToHolder(Wheel, Holder)
    if not (Wheel:IsA("BasePart") and Holder:IsA("BasePart")) then
        warn("Wheel or holder is not BasePart");
        return
    end

    Holder.CollisionGroup = "Body";
    Wheel.CollisionGroup = "Wheels";

    local WheelAttachment = createAttachment(Wheel, "WheelAttachment");
    local HolderAttachment = createAttachment(Holder, "HolderAttachment");

    if not Wheel:FindFirstChild("AO") then
        local AO = Instance.new("AlignOrientation");
        AO.Name = "AO";
        AO.Mode = Enum.OrientationAlignmentMode.OneAttachment;
        AO.RigidityEnabled = true;
        AO.Attachment0 = WheelAttachment;
        AO.Parent = Wheel;
    end

    if not Wheel:FindFirstChild("AP") then
        local AP = Instance.new("AlignPosition");
        AP.Name = "AP";
        AP.Mode = Enum.PositionAlignmentMode.TwoAttachment;
        AP.Attachment0 = WheelAttachment;
        AP.Attachment1 = HolderAttachment;
        AP.ForceLimitMode = Enum.ForceLimitMode.PerAxis;
        AP.ForceRelativeTo = Enum.ActuatorRelativeTo.Attachment0;
        AP.MaxAxesForce = Vector3.new(10000, 0, 10000);
        AP.Responsiveness = 100;
        AP.Parent = Wheel;
    end

    local SpringConstraint = Instance.new("SpringConstraint");
    SpringConstraint.Visible = true;
    SpringConstraint.Attachment0 = HolderAttachment;
    SpringConstraint.Attachment1 = WheelAttachment;
    SpringConstraint.Damping = 10;
    SpringConstraint.FreeLength = 7.5;
    SpringConstraint.Stiffness = 1000;
    SpringConstraint.LimitsEnabled = true;
    local Distance = (Wheel.Position - Holder.Position).Magnitude;
    SpringConstraint.MinLength = Distance;
    SpringConstraint.MaxLength = Distance + 2;
    SpringConstraint.Parent = Wheel;
end

--|< Main >|--
for _, wheel in ipairs(wheels:GetChildren()) do
    if wheel:IsA("Model") and wheel:FindFirstChild("Wheel") then
        local holder = wheels:FindFirstChild(wheel.Name .. "Holder");
        if holder then
            ConnectWheelToHolder(wheel:FindFirstChild("Wheel"), holder);
        end
    end
end

for _, part in ipairs(car:GetDescendants()) do
    if part:IsA("BasePart") then
        if part.Parent.Name == "Wheels" or part.Parent.Name == "Body" or part.Parent.Parent.Name == "Body" then
            part.CollisionGroup = "Body";
            local Weld = Instance.new("WeldConstraint");
            Weld.Part0 = main;
            Weld.Part1 = part;
            Weld.Parent = part;
        end
    end
end
1 Like


I test it, I unanchored an car then Car wheels are weird facing, Car wheels push car body then car moving away to void.

I not understand how it happend.

1 Like

Why not help me? I waitso long! If not then i repost beecause of not answer.

2 Likes

You might need to make your wheels spheres and not cylinders, As the cylinders give weird behaviour

i didnt read your issue i didnt realize oof

2 Likes

It works, thanks bro! Sphere works really nice!

2 Likes

Thats good to hear i thought i read your post wrong but i am happy to help have a good day :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.