How to make projectile shoot in the direction of the player

Hello! For my 2D game, one of the weapons is the classic rocket launcher. The problem is that most guns are designed to fire where the mouse is. Because it’s 2D, it hits the invisible walls designed to keep everything together, killing the player

How could I make it to only shoot in direction the weapon is facing, instead of the mouse’s placement, like an actual gun in real life?
I used the Rocket Launcher from Roblox

Because it’s a 2D game, one of the position x, y, or z are fixed. You probably see the solution.

1 Like

So, all I got to do is make a fixed axis?

Kind of a late reply but yeah, I think that will solve your problem.


K, I’ll look into the code and see what I can do

No, you gotta iintercept the mouse read in your guns and strip either the X or Z Values, depending on which way you sideways your world (Set it equal to the player’s or the mid-line of your world)

local X = Midline
local Pos = MouseLoc:InvokeClient(MyPlayer)
Pos = Vector3.New(X, Pos.y Pos.z)

Yo better strip it from the rocket’s origin as well or it could still go off at an angle.



What script would I tweak this in?
Client - Roblox Studio 12_6_2021 5_05_28 PM