Hello! I am confused on why my tool is not attaching…
There is only one part named “Handle” so welding is not the issue here.
I am trying to make it so that when you press a key you equip it, i’ve disabled the backpack so im using a script to equip the tool.
Here is the script:
if weapon.Value == "Dagger" then
weapon.Equipped.Value = true
local daggerClone = game.ReplicatedStorage.Weapons:WaitForChild("Dagger"):Clone()
human:EquipTool(daggerClone)
sound.SoundId = "rbxassetid://5917819099"
sound2.SoundId = "rbxassetid://2706199011"
sound:Play()
end
Everything works and the tool is in the character but it doesnt attach to the hand and instead falls on the ground in the spot where it was placed in the workspace.
print("Hello world!")
local player = game.Players.LocalPlayer
local character:Model = player.CharacterAdded:wait()
local humanoid:Humanoid = character:WaitForChild("Humanoid",10)
local RS = game:GetService("ReplicatedStorage")
local TERE:RemoteEvent = RS:WaitForChild("ToolEquipRE")
local ARE:RemoteEvent = RS:WaitForChild("ActivateRE")
-- Spawn a new part at TargetPoint when the tool is activated
function onActivated()
ARE:FireServer(humanoid.TargetPoint)
end
-- Make a new tool when the LocalScript first runs
TERE:FireServer()
local tool:Tool = character:WaitForChild("Tool",5)
print(tool.Name)
-- Handle tool use
if tool then
tool.Activated:Connect(onActivated)
end
Script:
local re = Instance.new("RemoteEvent")
re.Name = "ToolEquipRE"
re.Parent = RS
local are = Instance.new("RemoteEvent")
are.Name = "ActivateRE"
are.Parent = RS
-- Make a new tool and handle and put it in the player's Backpack
local function makeAndEquipTool(player,humanoid)
-- Create tool
local tool = Instance.new("Tool")
-- Place tool in backpack
tool.Parent = player:WaitForChild("Backpack")
-- Create tool handle
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Parent = tool
handle.BrickColor = BrickColor.Yellow()
handle.Size=Vector3.new(.3,.3,4)
local tip = Instance.new("Part")
tip.TopSurface = Enum.SurfaceType.Smooth
tip.BottomSurface = Enum.SurfaceType.Smooth
tip.Shape = Enum.PartType.Ball
tip.Size = Vector3.new(.4,.4,.4)
tip.CFrame = handle.CFrame:ToWorldSpace(CFrame.new(0,0,-2))
tip.BrickColor = BrickColor.Green()
tip.Parent = handle
local w = Instance.new("WeldConstraint")
w.Part0 = handle
w.Part1 = tip
w.Parent = handle
-- Enable and equip tool
tool.Enabled = true
humanoid:EquipTool(tool)
end
re.OnServerEvent:Connect(function(player)
makeAndEquipTool(player,player.Character.Humanoid)
end)
local function spawnPart(pos)
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(1,1,1)
part.Position = pos
part.Parent = game.Workspace
part.BrickColor = BrickColor.Blue()
part.TopSurface = Enum.SurfaceType.Smooth
part.BottomSurface = Enum.SurfaceType.Smooth
end
-- Create a new blue colored part at *pos* in the world
are.OnServerEvent:Connect(function(player,pos)
spawnPart(pos)
end)
Its a modified version of what is on the website for humanoid:EquipTool()