How to make hand follow a part

I am using this script to attach the gun to the hand, then to the head (this will be done when players presses Right Click, for testing purposes I kept it simple)

Server Script

local tool = script.Parent
local handle = tool:WaitForChild("Hrandle")
local aim = tool:WaitForChild("Aim")
local char
local rightHand
local head
local equipped
local aiming = false
local loaded = false




tool.Equipped:Connect(function()
	
	if not loaded then
		char = tool.Parent
		rightHand = char:WaitForChild("RightHand")
		head = char:WaitForChild("Head")
	end
	
	equipped = true
	
	
end)



repeat task.wait() until equipped == true



handle.CFrame = rightHand.CFrame
local joint = Instance.new("Motor6D")
joint.Part0 = handle
joint.Part1 = rightHand
joint.Parent = handle


task.wait(3)

joint:Destroy()
aim.CFrame = head.CFrame
local joint = Instance.new("Motor6D")
joint.Part0 = aim
joint.Part1 = head
joint.Parent = aim


The problem is, as you can see in the video, the hand doesn’t follow the gun (I know there is no code to do that now, I have no idea where to start).

I want it so that no matter where the gun goes, the whole right arm tries to reach to it, hold it.

Thank you in advance!

This is because the hand is literally jointed with a useless Motor6D (that I think should be a weld).

The reason why it’s not working is because the hand is jointed to something else with more mass, causing the part to follow the hand, which is clearly what you don’t want here.

So, you can either incline the mass of the other part or do this manually by setting the CFrame.

But again, I just want to say if the hand goes to the gun, the hand will be detached from the arm or bring the whole character with it, so you’ll need to create an animation.

I should clarify, I don’t want the hand to be attached to the gun like a wooden plank. I want it to point to the gun like in the gif in this post - Make hand follow your mouse target - Help and Feedback / Scripting Support - DevForum | Roblox

I tried to modify the script in that post, replacing mouse hit pos with gun’s handle, but the hand moved just up and down, and didn’t actually rotate inwards to the gun. Also it wasn’t really following the gun, it was following the camera, meaning the little shakes of the gun wouldn’t affect the hand, it would be still

To simplify, All I want to achieve is basic FPS aiming, but without using viewmodels.

So, for a first person shooter (FPS), you’d want something like this, am I right?

(sorry for the lag)

Yes, but what’s shown in the video is easily done by just a normal tool with a handle (I already tried it and it worked with another script). I want the player to be able to aim with a sight, when pressing right mouse button - this is what I cant achieve.

Ah, that. You might want to look into EasyFirstPerson as it has an AimOffset value inside its script. I’m not sure how else to do that without a viewmodel, though

It looks like it doesn’t have sight aim feature, what it has I already can do without it. + it has tons of bugs, and it uses a viewmodel, which I would really like to avoid

I have a script that moves the hand, but it is local and is not replicated to the server. (by the way I’m trying to do the same but for TPS)

Can you share please? Replication is not a problem, I can always modify it to replicate, and even if not, it’s not mandatory

script.Parent.Equipped:Connect(function()
	print(script.Parent.Parent.RightUpperArm.RightShoulder.C0)
	while wait() do
		local Character = script.Parent.Parent
		local Shoulder = Character.RightUpperArm:FindFirstChild("RightShoulder", true)
		local Root = Character:WaitForChild("HumanoidRootPart")
		local CameraDirection = Root.CFrame:toObjectSpace(workspace.CurrentCamera.CFrame).lookVector.unit

		Shoulder.C0 = CFrame.new(Shoulder.C0.p) * CFrame.Angles(math.asin(CameraDirection.y), -math.asin(CameraDirection.x), 0)
	end
end)

script.Parent.Unequipped:Connect(function()
	wait(0.1)
	script.Parent.Parent.Parent.Character.RightUpperArm.RightShoulder.CurrentAngle = 0
	script.Parent.Parent.Parent.Character.RightUpperArm.RightShoulder.DesiredAngle = 0
	script.Parent.Parent.Parent.Character.RightUpperArm.RightShoulder.MaxVelocity = 0
	script.Parent.Parent.Parent.Character.RightUpperArm:FindFirstChild("RightShoulder", false)
	script.Parent.Parent.Parent.Character.RightUpperArm.RightShoulder.C0 = CFrame.new(0.78999,0.58586,0.05672)
end)

it’s done on a tool, but it can be modified.

Yeah not at all what I’m looking for, I already have a script like this that moves the hand with the camera

if moveHand then
		local cameralookvectorY = workspace.CurrentCamera.CFrame.lookVector.Y
		local radian = math.asin(cameralookvectorY)
		char.RightUpperArm.RightShoulder.C0 = c0*CFrame.fromEulerAnglesYXZ(radian,0,0)
	end
end

Anyway I decided to do what I want with precise animations. I could’ve done it already If I spent on it 1/4 of the time I spent on looking an unnecessary perfect solution.

never mind. I knew it doesn’t do what you want, but it does a similar thing.

This may apply.

1 Like

Wow, that’s actually very smart lol, why didn’t I think of that.

I already did what I wanted to do with very precise animation, but if this works it might be easier, I’ll test and get back to you

The FPS game I’m currently making will make the arms the viewmodel, by putting them into the Camera’s CFrame with an offset.

It will change the weld of the arms to aim. A real viewmodel is technically not required at all.