I’m trying to make an ADS system for my FPS guns, but using welds doesn’t seem to be working, and I can’t use animations because that would be too much of a hassle to implement. I followed the tutorial by EgoMoose for the ADS, but nothing else on my gun system. I’ve tried playing around with the script, but nothing seems to be working. Any help is appreciated.
offset = arms.Camera.CFrame:inverse() * arms.Aim.CFrame;
local function aimDownSights(aiming)
if equipped then
local start = arms.Camera.AimJoint.C1;
local goal = aiming and arms.Camera.AimJoint.C0 * offset or CFrame.new();
aimCount = aimCount + 1;
local current = aimCount;
for t = 0, 101, 10 do
if (current ~= aimCount) then break; end
game:GetService("RunService").RenderStepped:Wait();
arms.Camera.AimJoint.C1 = start:Lerp(goal, t/100);
end
end
end
local function onInputBegan(input, process)
if (process) then return; end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
aimDownSights(true);
end
end
local function onInputEnded(input, process)
if (process) then return; end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
aimDownSights(false);
end
end
game:GetService("UserInputService").InputBegan:Connect(onInputBegan);
game:GetService("UserInputService").InputEnded:Connect(onInputEnded);
You haven’t described the problem you’re experiencing - is the sight not aligned? Is ADS not activating?
What have you tried to fix this?
Show a video or at least a picture of what problem you’re having.
Have you gone through EgoMoose’ tutorial again to check you haven’t missed anything?
You cannot expect volunteers here to do all the work for you - learning the script, guessing what it does, defining the expected behaviour vs what is actually happening.
The problem is, when I right click, nothing happens, at all. Here’s another solution I’ve tried:
offset = arms.HumanoidRootPart.CFrame:inverse() * arms.Aim.CFrame
local function aimDownSights(aiming)
if equipped then
if aiming == true then
arms.Aim.CameraJoint.C1 = offset
end
end
end
local function onInputBegan(input, process)
if (process) then return; end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
aimDownSights(true);
end
end
local function onInputEnded(input, process)
if (process) then return; end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
aimDownSights(false);
end
end
Currently, I have the aim part, and the HumanoidRootPart welded together, under the name “CameraJoint”. I’m trying to get the HumanoidRootPart to move the distance of the offset, to get it in line with the camera. I’m only using EgoMoose’s tutorial purely for the ADS, nothing else, so maybe that’s the problem, I’m not revamping my whole FPS script just for his ADS.
I presume you’ve actually defined the value “equipped” as a bool elsewhere in the script?
Essentially, you’re telling the script to only begin aiming if you’re already aiming. You should try changing if aiming == true then to if aiming == false then and see what happens.
That isn’t the issue, when I remove all the code within it and do a print("") function, it works as intended, and detects when it is being held down or not. The input is fine.