Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

Is it a local script?

1 answer

rocket.Orientation = CFrame.new(rocket.Velocity).lookVector

2 comments

0

That didn't work, it puts the rocket in a fixed 0,0,0 orientation when fired.

0

Bump

This discussion is preserved as it was. New answers, comments, and votes are closed.