How to make an aiming system?

Hello. Im Working on a hunting rifle gun that would shoot after I fixed the aiming problem
my exact problem is that player CAN aim but CANT move the gun up, down, left and right while aiming here is my script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character
local Enabled = false
local Anim

Mouse.Button2Down:Connect(function()
	Enabled = true
	if script.Parent.Parent:IsA("Model") then
		Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Aim)
		Anim:Play()
	end
end)

Mouse.Button2Up:Connect(function()
	Enabled = false
	Anim:Stop()
end)

game:GetService("RunService").Heartbeat:Connect(function()
	if script.Parent.Parent:IsA("Model") then
		if Enabled == true then
			game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
			game.Workspace.CurrentCamera.CFrame = script.Parent.AimPart.CFrame
		else
			game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		end
	else
		game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		if Aim ~= nil then
			Anim:Stop()
		end
	end
end)

What should i do to make it work correctly?

I am not good at making fps games I never touched custom camera but I think because its custom camera you have to add something that follow your Mouse Sight
(edit)
make CFrame make camera follows mouse sight

Alright but how?? I have no idea how do I do it

Also my gun is a tool Not model

Im bad at using cframe and I give up most of the time

is anchored ? (30 limit AAAAA)

No my tool is not anchored and its welded to handle

what you could do for aiming is changing the player fov instead as it would make everything easier

1 Like

Is there another way to do it? I want player’s camera at the gun aim thing position (Sorry i dont whats that called)

the gun sight you mean you probably have to use CFrame I think you’ll find tutorial on the internet

you can say CurrentCamera.CFrame = YourAimPartThing.CFrame

and then what you do is change the fov by saying

CurrentCamera.FieldOfView = desired fov

Thanks then how do i let players move the gun up, down, right, left by holding right click and moving the mouse?

use the mouse sight to move the camera because you are using custom camera you have to make every thing by your self
(I’m new scripter so I don’t know how to make this kind of stuff)
search on youtube about custom camera

I assume using TweenService | Roblox Creator Documentation will work. Use TweenService | Roblox Creator Documentation to modify the player’s camera position state. I don’t know much about TweenService | Roblox Creator Documentation so this might not work.

1 Like

this would make it so the player can move forward and offset the camera very badly. they would have to be standing still to make it work

Try multiplying the cam CF with the aimpart CF instead of directly setting it to the aim thing CFrame (workspace.CurrentCamera.CFrame *= script.Parent.AimPart.CFrame). Because you are setting the CFrame of the camera directly to the CFrame of the aim thing, you lose control over the camera.

Make a game:runservice.HearthBeat:Connect and if you are aiming rotate the player character humanoidRootPart with the mouse delta using UserInputService | Documentation - Hub Création Roblox input service : getMouseDelta.
Hope I helped anyone reading this post 3 years later

I wrote this from my phone sorry for the quality