enginne
(enginne)
December 8, 2021, 2:07pm
#1
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
enginne
(enginne)
December 8, 2021, 4:54pm
#3
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
Forummer
(Forummer)
December 8, 2021, 4:57pm
#4
Can you provide more of the script? Like how is “Aiming” determined?
1 Like
enginne
(enginne)
December 8, 2021, 4:58pm
#5
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
Forummer
(Forummer)
December 8, 2021, 5:00pm
#6
Where is “Aiming” declared and when is it given a value? Is it true by default and never changed?
enginne
(enginne)
December 8, 2021, 5:01pm
#7
Dude, the issue is the positioning of the arms, not the value, also is false as default.
Forummer
(Forummer)
December 8, 2021, 5:01pm
#8
Right, so if it’s never changed then the code above the else statement is never executed.
Forummer
(Forummer)
December 8, 2021, 5:03pm
#9
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
enginne
(enginne)
December 8, 2021, 6:08pm
#10
I think you didn’t got it, oof
C_Sharper
(Sharpie)
December 8, 2021, 6:30pm
#11
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.
enginne
(enginne)
December 8, 2021, 6:58pm
#12
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