I have a script which basically simulates sideways friction for a car and I tested it on a single part and works fine.
local Part = script.Parent local mass = script.Parent:GetMass() wait(2) game:GetService("RunService").Stepped:connect(function() local slidespeed = Part.CFrame:vectorToObjectSpace(Part.AssemblyLinearVelocity).X Part:ApplyImpulse(Part.CFrame:VectorToWorldSpace(Vector3.new(-slidespeed * mass * 0.7, 0, 0))) end)
But when I use this in my car script, it simply stops working. No errors, no effects visible.
Seat = script.Parent.VehicleSeat SteerMultiple = 0 SteerAngle = 0 CenterPart = script.Parent.VelocityPart local Car = script.Parent local mass = 0 for i, v in pairs(Car:GetChildren()) do if v:IsA("BasePart") then mass = mass + (v:GetMass()) print("add mass") end end Seat.Changed:Connect(function(Changed) if Seat.SteerFloat > 0 then SteerAngle = 30 elseif Seat.SteerFloat < 0 then SteerAngle = -30 elseif Seat.SteerFloat == 0 then SteerAngle = 0 end script.Parent.TestedThing.SteerHinge.TargetAngle = SteerAngle script.Parent.TestedThing2.SteerHinge.TargetAngle = SteerAngle script.parent.TestedThing.BodyThrust.Force = Vector3.new(0, 0, Seat.ThrottleFloat * -2000) script.Parent.TestedThing2.BodyThrust.Force = Vector3.new(0, 0, Seat.ThrottleFloat * -2000) script.Parent.TestedThing3.BodyThrust.Force = Vector3.new(0, 0, Seat.ThrottleFloat * -2000) script.Parent.TestedThing4.BodyThrust.Force = Vector3.new(0, 0, Seat.ThrottleFloat * -2000) end) local function UpdateWheel(Wheel) local slidespeed = Wheel.CFrame:vectorToObjectSpace(Wheel:GetVelocityAtPosition(Wheel.Position)).X local ImpulseValue = Vector3.new(-slidespeed * mass * 0.25 * 0.7, 0, 0) local ImpulseWorld = Wheel.CFrame:VectorToWorldSpace(ImpulseValue) Wheel:ApplyImpulseAtPosition(ImpulseWorld, Wheel.Position) game.Workspace["Impulse Test"]:ApplyImpulseAtPosition(ImpulseWorld, game.Workspace["Impulse Test"].Position) end game:GetService("RunService").Stepped:connect(function() for i, part in pairs(Car:GetChildren()) do if part.Name == "TestedThing" or part.Name == "TestedThing2" or part.Name == "TestedThing3" or part.Name == "TestedThing4" then UpdateWheel(part) end end end)
I have hinges turning the wheel blocks on the front and hinges connecting wheels which are just there to let the car roll forward and backward. The wheels have basically no friction so that I could test this system which hasn't been working.
The TestedThings are the thruster/wheels.
I tried without the "* 0.25" before and it didn't change anything.
Impulse World and Value are separate just for testing purposes and they used to be one operation before I split it.
Could the hinges be stopping impulse from working?
The Impulse Test block is a heavy block I placed unanchored to apply the same impulses on and it seems to get the proper impulses which the wheels should be getting.
I've changed everything that comes to mind and not a single change can be seen.