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

Why won't any vector for the bodyforce thrust the right direction?

Asked by
2b2tpvp 17
3 years ago

So I have a spaceship with thrusters and I want the spaceship to go forward (It's facing towards +Z), but it tilts all the wrong directions for some reason. The bodyforce is in the floor of the faceship and here is my script.

local isOn=false
function on()
    isOn=true
    script.Parent.BrickColor=BrickColor.new("Bright green")
    script.Parent.Parent.Floor.BodyThrust.Force=script.Parent.Parent.Floor.CFrame.LookVector*script.Parent.Speed.Value
    print(script.Parent.Parent.Floor.BodyThrust.Force)
end
function off()
    isOn=false
    script.Parent.BrickColor=BrickColor.new("Really red")
    script.Parent.Parent.Floor.BodyThrust.Force=Vector3.new(0,0,0)
end
function onClicked()
    if isOn==true then off() else on()end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
off()

Here's a video of what happens.

https://gyazo.com/baa8c4ee89fb1d92dc7fe360d8a705ec

1 answer

Log in to vote
0
Answered by 3 years ago

Use a BodyGyro to prevent the rocket ship from turning in unwanted directions.

Ad

Answer this question