Hi,
I got this code from a youtube tutorial. It makes you equip a tool on your back when you are not holding it. It works good until i hold the tool, the tool on my back is not removed. Any toughts on this?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BackTools = ReplicatedStorage:WaitForChild("BackTools")
local Character = script.Parent
local UpperTorso = Character:FindFirstChild('UpperTorso') or Character:FindFirstChild('Torso')
local OldModel = nil
function Weld(weldMe, toThis)
local weld = Instance.new("Weld")
weld.Part0 = weldMe
weld.Part1 = toThis
weld.C0 = weldMe.CFrame:ToObjectSpace(toThis.CFrame)
weld.Parent = toThis
end
Character.ChildRemoved:Connect(function(child)
local Model = BackTools:FindFirstChild(child.Name)
if child:IsA('Tool') and Model then
if OldModel then
OldModel:Destroy()
end
OldModel = Model:Clone()
OldModel:SetPrimaryPartCFrame(UpperTorso.CFrame)
OldModel.Parent = workspace
Weld(OldModel.PrimaryPart, UpperTorso)
end
end)