Converting Tool.Grip to RightGripAttachment

I’m trying to Convert Tool.Grip to RightGripAttachment by figuring out the Offset of the Tool.Handle, but I’m not sure which CFrame Method to use and how to use it.

New_RightGripAttachment.Position = Character.RightHand.RightGripAttachment.CFrame:ToObjectSpace(Handle.CFrame).Position

The results aren’t quite right

1 Like

I got the position correct with this formula:

New_RightGripAttachment.Position = (Character.RightHand.RightGripAttachment.WorldCFrame:Inverse() * Handle.CFrame).Position

I also solved for the orientation using CFrame, since it was off in your repro file anyway:

New_RightGripAttachment.CFrame = Character.RightHand.RightGripAttachment.WorldCFrame:Inverse() *
Handle.CFrame * CFrame.Angles(math.pi/2,math.pi,0) * CFrame.new(0,-1,0)

I actually simplified it to this with some experimenting:

local Tool = --tool here
New_RightGripAttachment.CFrame = Tool.Grip * Character.RightHand.RightGripAttachment.CFrame:Inverse()

NOTE: THIS ONLY WORKS WITH R6 SO FAR!

Edit: I settled for a system that switches between R6 grips and R15 grips, since there is no “one CFrame fits all” solution:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Cha)
		local New_Accessory = Accessory_Clone:Clone()
		if Cha.Humanoid.RigType == Enum.HumanoidRigType.R6 then
			New_Accessory.Handle.RightGripAttachment.CFrame = Tool.Grip * RightHandGrip.CFrame:Inverse()
		elseif Cha.Humanoid.RigType == Enum.HumanoidRigType.R15 then
			New_Accessory.Handle.RightGripAttachment.CFrame = Tool.Grip
		end
		Cha.Humanoid:AddAccessory(New_Accessory)
	end)
end)
5 Likes

Wow, Thank you!

So it’s as simple as

RightGripAttachment.CFrame = Tool.Grip



1 Like