Orientation of Rocket is always 90 degrees wrong

I am creating a Rocket Launcher, however as seen in the image below, the rocket is rotated 90 degrees of how it should really be. It’s always 90 degrees wrong no matter what direction you are looking.
I am not very good with CFrames, so help would be appreciated.
image

The part of the script that creates the rocket:

			local RocketHole = Tool:FindFirstChild("RocketHole")
			local Rocket = game.ServerStorage.Rocket:Clone()
			Rocket:PivotTo((CFrame.new(RocketHole.Position,MousePos)))
			Rocket.Parent = workspace

RocketHole is a part inside the rocket launcher which is correctly rotated, and MousePos is the player’s mouse position.

The solution might be simple, however CFrames confuse me.
Thanks for your help.

Which part is the primary part of the Rocket model? I’m assuming it’s the long cylinder. If it is, then are you using Roblox’s cylinder part for that?

Yes, it’s the long cylinder, and it is also the Roblox’s cylinder.
image

Here’s a visual representation of what you’re experiencing (Cylinder starts from red part and faces the blue part):
image

The highlight shows you the Front face of the cylinder. That is why it’s always rotated 90 degrees regardless of which direction you fire from. If you wanted to have it rotated correctly, you could just do this:

--lookAt is equivalent to CFrame.new(pos1, pos2)
Rocket:PivotTo(CFrame.lookAt(RocketHole.Position,MousePos) * CFrame.Angles(0, math.rad(90), 0))
3 Likes

Thanks, that worked. However, it is still facing the wrong direction, but thanks for the help, I can probably fix this.

Is it facing 180 degrees opposite of what you want it to?

Yes, I managed to fix it, thank you for your help.

Rocket:PivotTo(CFrame.lookAt(RocketHole.Position,MousePos) * CFrame.Angles(math.rad(180), math.rad(90), 0))
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.