Okay so I’m trying to make a gun that you can aim down and shoot and everything, and I’ve already scripted it from scratch to the point where I don’t want to rework the entire thing or make a new one when I’m this close.
I want the gun and arms to be visible and to move up and down with the player, and I’ve managed to do just that. The problem is that whenever I go into first person and look up or down the camera detaches form where I want it to be aiming. The video shows what I mean.
I’ve tried multiple things to fix this, like a part welded to the tool that I set the camera CFrame to, but anything like that ends up making the camera rotate in first person constantly. Any ways of fixing this?
3 Likes
You need to make the arms longer, make it more close to the body, or change the CameraSubject from Current Camera. Since the arms are visible and the torso isn’t it makes the arms look like it is detached.
Let me know if this doesn’t work.
It’s not that I want the arms to look attached, I’m trying to making it so when the playing aims, the mouse stays above the top of the gun no matter how high or low they aim. I don’t really want to use a viewport because then I would have to redo everything, and I still want the player to be able to go in and out of first person.
I’m a bit confused on what you saying. Are you trying to keep the arm still from moving when the player moves up down aim?
In that case, I’m not sure what your script look, but I’m assuming you are using Angle CFrame and Camera movement. In that case just remove it from the script or something. I would be willing to help more if you can show that the script look like.
I’m pretty sure there is many more ways but I don’t got time checking.
No, I want the arms to move but I want the camera to move with them so they stay in the same spot on the screen. This is the code:
local char = player.Character
local orgRightc0 = char.Torso["Right Shoulder"].C0
local orgLeftc0 = char.Torso["Left Shoulder"].C0
runservice.Heartbeat:Connect(function()
if equipped then
local rightX, rightY, rightZ = char.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
char.Torso["Right Shoulder"].C0 = (char.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))
local leftX, leftY, leftZ = char.Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()
char.Torso["Left Shoulder"].C0 = (char.Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mouse.Hit.p - -mouse.Origin.p).unit.y))
else
char.Torso["Right Shoulder"].C0 = orgRightc0
char.Torso["Left Shoulder"].C0 = orgLeftc0
Root.CFrame = CFrame.new(Root.Position, Vector3.new(mouse.Hit.Position.X, Root.Position.Y, mouse.Hit.Position.Z))
end
end)
1 Like
Alright after looking at the video like multiple times. I think I have figured it out what you meant.
It isnt really the camera, but it actually the arms itself. You see as the video shows when you when you look up and down in 0:06 - 0:09. The arm detaches from yourself. I could figure that it is the animation that is causing it. Not sure if you make the animation priory to Action, or disabling the arms collision.
Or your tool has collision on which kind of interfere with the positioning on the arm. I haven’t tested the script to see what it is going on since I don’t know where it goes. But I assume that Root.CFrame in line 16 (mouse.Hit.Position.Z) should be removed.
I will look more into it later but try those first.