I’m currently working on an aiming script for my FPS gun that im making, Right now I Already have a script that makes the camera move to the impart but the problem is that I can’t move my camera up or down, left ,right.
this is the code:
local player = game:GetService(“Players”).LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local RunService = game:GetService(“RunService”)
local tool = script.Parent
local aimpart = tool.AimPart
does anyone know how to solve it and how I can get it the camera then moving again? also does anyone know how to get back to your normal camera position so ur not aiming anymore?
the thing is that my camera is on the right position on the gun but I can’t move the camera anymore. so I can aim up or down or whatever.I just stay stuck there. only my camera is stuck btw, I can still move
thanks, this is already a solution for half the problem. as you see in the game, for some reason I can’t move my mouse when I aim. do you know how I can fix that
this is what I have now and the start and stop aiming works as you can see in the test game.
local player = game:GetService(“Players”).LocalPlayer
local char = player.Character
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local RunService = game:GetService(“RunService”)
local tool = script.Parent
local aimpart = tool.AimPart
local connection
local equiped = true
tool.Equipped:Connect(function()
equiped = true
mouse.Button2Down:Connect(function()
if equiped == true then
camera.CameraSubject = aimpart
connection = RunService.RenderStepped:Connect(function()
camera.CFrame = aimpart.CFrame
end)
end
end)
This tutorial covers the aiming part, they simply tween the AimPart of the gun to the Camera, I think what you gotta do is just manipulate the CFrames of your Arms(Motor6ds)
I’v looked stuff up about manipulation of motor6D but I still don’t understand how I could change the frame of the arm that way and I wouldn’t know how to put the arms back either.
this really helped out a lot already but there is something wrong I think.
code:
local player = game:GetService(“Players”).LocalPlayer
local char = player.Character
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local RunService = game:GetService(“RunService”)
local tool = script.Parent
local Arm = char:WaitForChild(“RightUpperArm”)
local Shoulder = Arm:WaitForChild(“RightShoulder”)
local ShoulderOriginC0 = Shoulder.C1
local connection
local equiped = true
tool.Equipped:Connect(function()
equiped = true
mouse.Button2Down:Connect(function()
if equiped == true then
connection = RunService.RenderStepped:Connect(function()
char:WaitForChild(“RightUpperArm”).RightShoulder.C0 = ShoulderOriginC0 * CFrame.Angles(0,0,1)
end)
end
end)
end)
I ran into 2 problems:
the first problem is that it for some reason only rotates the tool and the other one is that I already have another script that uses the shoulder his C0 so the tool follows the mouse.
-- You can use this, INSIDE THE CONNECTION
local camDir = char.HumanoidRootPart.CFrame:ToObjectSpace(camera.CFrame).LookVector
local rot = CFrame.Angles(-math.asin(camDir.Y), math.asin(camDir.X), 0)
CF = CF * rot