I need help to make ironsight aim

So i am trying to make that when you hold the left mouse button and you’re in first person, it makes you aim the gun (ironsight aim)

This is normal view

This is when i try to aim

i don’t know how to fix this, so if anybody could help me, i would really love that

here a piece of script that manipulates the aiming:

					local Tool = Character:FindFirstChildOfClass("Tool")
					local AimPoint = Tool:FindFirstChild("Aimpoint")
					if Aiming then 
					
						if Character.Torso:FindFirstChild("Right Shoulder") then Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(1, -1, -0.5)):toObjectSpace(AimPoint.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), 0.5/2) end
						if Character.Torso:FindFirstChild("Left Shoulder") then Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(-1, -1, -0.5)):toObjectSpace(AimPoint.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), 0.5/2) end
					else
						
				
					if Character.Torso:FindFirstChild("Right Shoulder") then    Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(1, -1, -0.5)):toObjectSpace(Character.Torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), 0.5/2) end
					if Character.Torso:FindFirstChild("Left Shoulder") then Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(-1, -1, -0.5)):toObjectSpace(Character.Torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), 0.5/2) end
					end
1 Like

I don’t need a scope ui, i want that the pistol gets in the center of my screen, and aim with the ironsight

1 Like

Can you provide more of the script? Like how is “Aiming” determined?

1 Like

Here `local Tool = Character:FindFirstChildOfClass(“Tool”)
local AimPoint = Tool:FindFirstChild(“Aimpoint”)
if Aiming then

					if Character.Torso:FindFirstChild("Right Shoulder") then Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(1, -1, -0.5)):toObjectSpace(AimPoint.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), 0.5/2) end
					if Character.Torso:FindFirstChild("Left Shoulder") then Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(-1, -1, -0.5)):toObjectSpace(AimPoint.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), 0.5/2) end
				else
					
			
				if Character.Torso:FindFirstChild("Right Shoulder") then    Character.Torso["Right Shoulder"].C0 = Character.Torso["Right Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(1, -1, -0.5)):toObjectSpace(Character.Torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), 0.5/2) end
				if Character.Torso:FindFirstChild("Left Shoulder") then Character.Torso["Left Shoulder"].C0 = Character.Torso["Left Shoulder"].C0:lerp((Camera.CoordinateFrame * CFrame.new(-1, -1, -0.5)):toObjectSpace(Character.Torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), 0.5/2) end
				end`

this part it’s inside a loop, that checks the Value (Aim value), the Value it’s changed from 2 functions that is connected to the mouse Button event

1 Like

Where is “Aiming” declared and when is it given a value? Is it true by default and never changed?

Dude, the issue is the positioning of the arms, not the value, also is false as default.

Right, so if it’s never changed then the code above the else statement is never executed.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
	--modify grip position of gun
end)

mouse.Button1Up:Connect(function()
	--revert grip position of gun back to normal
end)

I’ll just leave this here as an example of what you should be doing.

1 Like

I think you didn’t got it, oof

What happens if you add a 90 degree rotational offset to the calculated CFrame?

It sort of looks like it’s sticking straight up, maybe by tweaking the values a bit you can get it in a better location.

Nope, because we have to update the arms direction with the Aimpoint direction, because it’s rotating with the gun unlike the torso

1 Like