Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make the FPS arms stay with the camera?

So, I'm making a gun for an FPS. I already have the script for showing the FPS arms, and animations, etc. I'm just having trouble with having the arms follow the camera. Basically, I want the torso to move to the Y point of the camera but I don't want the legs to move with the torso. I have this code here:

mouse.Move:connect(function()
		mouse.TargetFilter = game.Workspace
   		torso.CFrame = CFrame.new(torso.Position, Vector3.new(mouse.Hit.p.X, 			  mouse.Hit.p.Y, mouse.Hit.p.Z))
end)

It works decently, but if your arms touch the ground then it like flings you and makes you fall. Also, the entire body moves; like, the legs also float with the torso. I want the legs to stay flat on the ground, and only have the torso move up and down on the Y axis according to the Y of the mouse. I was thinking of making the head move with the Y and welding the arms to the head, but I'm not sure to do that. Could anyone help me please? Thanks!

2 comments

0

I think the flinging problem can be solved by setting CanCollide of the arms to false?

0

Set the arms CanCollide property to false, also, you can use CFrame.new(torso.Position, mouse.Hit.p) instead of your whole vector3 stuff. The reason your legs move is because you set the CFrame of the torso. set the CFrame of the welds inside the torso instead.

1 answer

for FPS I prefer to use R6 real arms this is my local script:

plr = game.Players.LocalPlayer;
repeat wait() until plr.Character
char = plr.Character
m = plr:GetMouse()
game["Run Service"].RenderStepped:connect(function()
local c = game.Workspace.CurrentCamera

char.HumanoidRootPart["RootJoint"].C0 = CFrame.new(0,0,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)

	char.Humanoid.CameraOffset = (char.HumanoidRootPart.CFrame+Vector3.new(0,0,0)):pointToObjectSpace(char.Head.CFrame.p + Vector3.new(0,-1.46,0))

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.