You can write your topic however you want, but you need to answer these questions:
-
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. -
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. -
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)