Mouse Position based gun orientation

Topic - Weapon Systems

Hello, 2nd devforum post by the way

So, if anyone reading this has played armored patrol
Armored Patrol v9.5 - Roblox (newer version)
They’d know that the gun system, the way to represent aiming in it is to make the characters rotation and the arm rotations where the mouse is pointing
an example:


– Luke


Well, you’d probably need to detect the changes made every time the Mouse moves so you’ll need to use a LocalScript for this Instance

You can get the Mouse by doing Player:GetMouse(), and using the RenderStepped event from the RunService you can detect where you want the Character to look at (Hopefully in a smooth transition?):

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Root = Character:WaitForChild("HumanoidRootPart")

    local MousePos = Mouse.Hit.Position
    Character:SetPrimaryPartCFrame(,, Root.CFrame.Position.Y, MousePos.Z))

For the character facing the where the gun is, I believe you can use Motor6D’s:


How would I use motor 6d’s?

sorry but it wouldnt let me post because i need more characters

You can use them to animate Tool objects I believe

Here’s a good tutorial on how to use them in relation with weapons:

1 Like

man, i was kinda dumb when i first posted this and was just looking for someone to write a script for me. oh well, time has passed and i’m looking into this stuff again. anyways, thanks for this, very helpful now that i know more about lua and what not.