I’m making a custom weld to hand system that needs to be compatible with all tools, including tools not made by me. How would I go about welding a tool to a character’s hand with tool grip offsets? All other posts I’ve seen just discuss how to weld the tool to a character’s hand. This method isn’t compatible with all tools, as some tools have grip offsets, and will not display correctly in the character’s hand without them in effect.
Can’t you just take the player’s hand’s CFrame and add on another CFrame with the offset. For example,
tool.CFrame = player.Character.RightHand.CFrame * CFrame.new(0,3,0)
Or you could change the C0 of the weld?
Can you give me an example of what you mean? I’ve never used welds before.
If you are using a normal weld, then the weld will have a property called C0 and a property called C1. Basically what a weld is is it attached two parts together so that when 1 moves the other moves with it. They are always at a consistent distance relative to each other. So changing the C0 changes the where one of the parts is relative to the other and changing the C1 changes where the other part is relative to the other.
local weld = --define here
weld.C1.CFrame = weld.C1.CFrame * CFrame.new(0,3,0)
--Will move the part 3 studs up without moving the part that it is attached to.
local function GetClosestPart(m: Instance,from: Vector3)
local dist=math.huge
local t=nil
for i, v in m:GetChildren() do
if v:IsA(“BasePart”) then
local d=(v.Position-from).Magnitude
if d<dist then
dist=d
t=v
end
end
end
return t
end
local instancenew=Instance.new
tool.Equipped:Connect(function()
for i, v in handle:GetChildren() do
if v.Name==“RightGrip” then
v:Destroy()
end
end
local ClosestPart=GetClosestPart(tool.Parent,handle.Position)
local Weld=instancenew(“Weld”,ClosestPart)
Weld.Part0=ClosestPart
Weld.Part1=handle
Weld.C0=CFrame.new(0,-1,0)*CFrame.Angles(math.rad(-90),0,0)
Weld.C1=tool.Grip
Weld.Name=“Grip”
end)