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

Is LookVector and BodyForce/velocity broken?

Asked by
Argore -9
5 years ago

So... I tried using the lookVector for my boat, but for some reason, it only goes one way and doesn't change depending on where I'm (the vehicle seat is) looking. I tried using both BodyForce and BodyVelocity but nothing seems to work.

The script i used:

force = script.Parent.Parent.base.base.BodyVelocity
look = script.Parent.CFrame.LookVector


while true do
    if script.Parent.Throttle == 1 then
        force.Velocity = look * 8000
    end
    if script.Parent.Throttle == 0 then
        force.Velocity = look * 0
    end
    wait(0.1)
end

I can't find any answer to why this happens. The script is inside a seat.

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

No they're not broken.

You're assuming that with line 2, the variable would update if the value is changed, but this isn't the case, once assigned to a value, it will be always be the same.

force = script.Parent.Parent.base.base.BodyVelocity
part = script.Parent


while true do
    if script.Parent.Throttle == 1 then
        force.Velocity = part.CFrame.LookVector * 8000
    end
    if script.Parent.Throttle == 0 then
        force.Velocity = part.CFrame.LookVector * 0
    end
    wait(0.1)
end

If you have any questions/I made a typo/dumb mistake, just tell/ask!

Have a nice day

0
thank you so much! it helped. have a nice day to you too :) Argore -9 — 5y
Ad

Answer this question