Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to disable Body Movers when the part is in mid-air?

Asked by 3 years ago

In short, I am currently making a car that is powered by BodyVelocity to get it moving. And although the car works well, the problem is is that once it drives up or down the wedge, it starts flying until the player no longer accelerates. Is it possible to temporarily turn Body Movers off if the car is not interacting with any of the parts? I will provide the script for further context:

script.Parent:GetPropertyChangedSignal("Throttle"):Connect(function()
    if script.Parent.Throttle == 1 then
        script.Parent.Parent.MainPart.BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
        script.Parent.Parent.MainPart.BodyVelocity.Velocity = script.Parent.Parent.MainPart.CFrame.LookVector * 95
     elseif script.Parent.Throttle == 0 then
        script.Parent.Parent.MainPart.BodyVelocity.MaxForce = Vector3.new(0, 0, 0)
        script.Parent.Parent.MainPart.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
     elseif script.Parent.Throttle == -1 then
        script.Parent.Parent.MainPart.BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
        script.Parent.Parent.MainPart.BodyVelocity.Velocity = script.Parent.Parent.MainPart.CFrame.LookVector * -85
    end
end)

script.Parent:GetPropertyChangedSignal("Steer"):Connect(function()
    if script.Parent.Steer == 1 then
        script.Parent.Parent.MainPart.BodyAngularVelocity.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
        script.Parent.Parent.MainPart.BodyAngularVelocity.AngularVelocity = Vector3.new(0, -1, 0)
    elseif script.Parent.Steer == 0 then
        script.Parent.Parent.MainPart.BodyAngularVelocity.MaxTorque = Vector3.new(0, 0, 0)
        script.Parent.Parent.MainPart.BodyAngularVelocity.AngularVelocity = Vector3.new(0, 0, 0)
    elseif script.Parent.Steer == -1 then
        script.Parent.Parent.MainPart.BodyAngularVelocity.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
        script.Parent.Parent.MainPart.BodyAngularVelocity.AngularVelocity = Vector3.new(0, 1, 0)
    end
end)
0
wdym interacting User#30567 0 — 3y
0
Interact, as in touching them. MysteriousCeburek 27 — 3y
0
if BasePart:GetTouchingParts() == {} then ... end User#30567 0 — 3y

Answer this question