How Can I Make My Gun Aim

I am trying to make a gun framework and cannot work out how to make the gun aim if the player holds right click. i know i need to use UIS/Mouse which i have done but i cant get it to smoothly animate to the aim pos, or even aim at all.

my gun is in

workspace.CurrentCamera

so i am using RenderStepped

How would i do this? i am trying to make the aiming similar to the ones in phantom forces

3 Likes

Try looking at this resource: The First Person Element Of A First Person Shooter

3 Likes

hmm, time to get to rewriting almost my entire system

1 Like

Just use the math as a reference for the aiming, not rewrite the entire thing. I quoted the main section you will wanna use.

1 Like

You can just use this function.

3 Likes

ok, thank you. i will see if it works

2 Likes

whats the joint part supposed to mean, I dont understand.

You can use a ModuleScript and state the AimSpeed, then in a localscript in StarterPlayer you can do:

local aimCF = CFrame.new()
if isAiming and framework.viewmodel ~= nil and framework.module.canAim then
		local offset = framework.viewmodel.AimPart.CFrame:ToObjectSpace(framework.viewmodel.PrimaryPart.CFrame)
		aimCF = aimCF:Lerp(offset, framework.module.aimSpeed)
end