How to point a weapon into the direction of the camera

Hi everyone, FlashDrive284 here (my account has a wrong DOB for some reason so I can’t use it here). As Jailbreak players would know, when players are using weapons such as a pistol, the pistol will always point the camera direction. Although I have been using Roblox Studio for a year or two, this question has been bugging me for a while now. I have 3 weapons in my game and I haven’t been able to somehow incorporate this.

I cannot figure out to point the tool in the direction of the player’s camera.

I have searched the web quite a lot, however haven’t come to any conclusion.

P.s. Sorry if I sound too noob-ish. This is my first post on here, and I don’t have full experience into core mechanics in Roblox.

1 Like

There is a plugin you can buy were you can change the tool in your hand that I can link to you and this may help but I don’t super understand what you are asking,

CFrame is your best bet. It handles every orientation and angle and position. As for getting the direction the hand needs to look in, just go to the Roblox API and look through the Camera Documentation. Camera.CFrame.lookVector tells you where the player is looking.

Do note that anything related to the camera has to be done in a local script because only the client has access to the camera.

Sorry, if I have phrased the question a little wrong, but put simply, I would like to achieve weapons/tools that face the camera, so it is like the weapons in Jailbreak.
Also, thx for the fast reply.

So the weapon is facing towards the body and not out like a gun should be?

Do you think theres a way to rotate the lower torso (we’re talking R15 characters btw) to the camera lookVector?

No, I mean that the weapon is pointing out forward. The player is always (away) from the character.

Wait, sorry I mean the character is always turned away from the camera.

Yeah, there is this thing called a Motor6D which basically handles all animation joint rotations. You can try editing the CFrame value of the Motor that handles the torso rotations.

Also, I know this sounds like Shift Lock, though I was having a few issues with that, so I would like to hard code it myself.

Okay, quick update: I found some code for Head Rotation, changed a few things and have come up with this simple tool that does pretty much what I want. Thank you, everyone, for your quick responses!
Here’s the result, if anyone has any suggestions. Baseplate.rbxl (18.8 KB)

p.s. also, please don’t be put back by its simpleness, I still need to edit it to fit my tools.

4 Likes