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

How do i make a part point towards it's velocity?

Asked by
Drainhp 41
7 years ago

Hello! I am trying to script a rocket launcher. With my rocket launcher, i want the rockets to always point towards it's own velocity when fired, just like how an arrow would fly through the air. I can't seem to find out how to do that though. This is my script:

while wait() do
    rocket.CFrame = CFrame.Angles(rocket.Velocity)
end

This doesn't work, it just throws me an error.

Full script:

tool = script.Parent
Handle = tool.Handle

launcher = tool.Launcher

tool.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
        local rocket = game.ServerStorage.Rocket:Clone()
        rocket.Parent = workspace
        rocket.CFrame = CFrame.new(launcher.CFrame.p, mouse.Hit.p)
        rocket.Velocity = rocket.CFrame.lookVector * 100
        while wait() do
        rocket.CFrame = CFrame.Angles(rocket.Velocity)
        end
    end)
end)
0
Is it a local script? saSlol2436 716 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
rocket.Orientation = CFrame.new(rocket.Velocity).lookVector
0
That didn't work, it puts the rocket in a fixed 0,0,0 orientation when fired. Drainhp 41 — 7y
0
Bump Drainhp 41 — 7y
Ad

Answer this question