I am trying to make a custom tool that the player get when they click a part, everything is fine, but when he does click the part the “axe” is not positions in his hand, just floating somewhere else. Help pls?
local CD = script.Parent.ClickDetector
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Axe = ReplicatedStorage.Axe
CD.MouseClick:Connect(function(player)
local NewAxe = Axe:Clone()
local character = player.Character or player.CharacterAdded:Wait() -- gets the player's character
local humanoid = character:FindFirstChildOfClass("Humanoid") -- get the humanoid
NewAxe.Parent = player.Backpack -- put in backpack
humanoid:EquipTool(NewAxe) --equip the tool
local weld = Instance.new("WeldConstraint")
weld.Part0 = player.Character["Right Arm"]
weld.Part1 = NewAxe.Handle
weld.Parent = NewAxe.Handle
end)
You are trying to weld via WeldConstraint which “locks” relative position. When you copying axe from ReplicatedStorage position of this part is somewhere in world where did you leave it before
You can try:
move part to hand before you weld them(also you need to turn off Tool.RequiresHandle and rename Handle to something else)
Also looks like you are trying to fix it in right hand which is default to weld. Try use Tool.Grip which can be modified manually or via popular plugin Tool Grip Editor
So I did this (Used weld) and it still does not work.
local CD = script.Parent.ClickDetector
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Axe = ReplicatedStorage.Axe
CD.MouseClick:Connect(function(player)
local NewAxe = Axe:Clone()
local character = player.Character or player.CharacterAdded:Wait() -- gets the player's character
local humanoid = character:FindFirstChildOfClass("Humanoid") -- get the humanoid
NewAxe.Parent = player.Backpack -- put in backpack
humanoid:EquipTool(NewAxe) --equip the tool
local weld = Instance.new("Weld")
weld.Part0 = NewAxe.Handle
weld.Part1 = player.Character["Right Arm"]
weld.Parent = NewAxe.Handle
end)
Parts with name Handle will always automatically weld to right arm.
If you want to weld parts to other character parts, rename Handle to something else(disable Tool.RequiresHandle) and weld it as regular part, but in this case right arm will not lift up.
If you want to keep right arm lifted up and just change axe position in arm use Tool.Grip without any weld instead(highly recommended use plugin Tool Grip Editor).
If it still doesn’t work out, may I ask what exactly are you trying to do? Shift the axe to the right hand, somehow move the axe around the arm? I’m afraid I’m advising something superfluous