Tool Cloning to workspace doesn't work correctly

I have coded a drop function that clones a tool from ReplicatedStorage and parent it to a folder in workspace.

local function DropItem(player, item)
	local data = Inventory.Get(player.UserId)
	local itemInfo = ItemsInfo[item]

	if not data or not itemInfo or not itemInfo.Droppable then return end
    
    
    if Inventory.RemoveItem(item, player.UserId, 1) then --check if player actually has the item to drop
        
		local itemModel = itemInfo.Model:Clone()
		if itemModel then
			itemModel.Parent = Interactables
			if itemModel:IsA("Tool") then 
				itemModel = itemModel.Handle
				if itemModel:FindFirstChild("TouchInterest") then
					itemModel.TouchInterest:Destroy()
				end
            end
            
            local prox = Instance.new("ProximityPrompt")
            prox.HoldDuration = .5
            prox.ActionText = "Pickup"
            prox.Parent = itemModel
            
            player.Character.Humanoid:UnequipTools()
            itemModel.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0, 0, -2)
		end
	end
end


The problem is that only the Handle is visible, even though in the explorer, I can see all the parts.
I changed the itemModel to another part, and now I can see it but not the Handle and the left part!

All the parts and the tool is Archivable, and Transparency = 0

I need help ASAP, any idea is appreciated.

I used chatgpt and he solved the issue

local function DropItem(player, item)
    local data = Inventory.Get(player.UserId)
    local itemInfo = ItemsInfo[item]

    if not data or not itemInfo or not itemInfo.Droppable then return end
    
    if Inventory.RemoveItem(item, player.UserId, 1) then --check if player actually has the item to drop
        local itemModel = itemInfo.Model:Clone()
        if itemModel then
            itemModel.Parent = Interactables

            if itemModel:IsA("Tool") then 
                local handle = itemModel:FindFirstChild("Handle")
                if handle then
                    if handle:FindFirstChild("TouchInterest") then
                        handle.TouchInterest:Destroy()
                    end

                    -- Add proximity prompt to the handle
                    local prox = Instance.new("ProximityPrompt")
                    prox.HoldDuration = 0.5
                    prox.ActionText = "Pickup"
                    prox.Parent = handle

                    -- Position the whole tool near the player
                    local hrp = player.Character.HumanoidRootPart
                    for _, part in pairs(itemModel:GetDescendants()) do
                        if part:IsA("BasePart") then
                            part.CFrame = hrp.CFrame * CFrame.new(0, 0, -2)
                        end
                    end
                end
            else
                -- If not a tool, just add ProximityPrompt
                local prox = Instance.new("ProximityPrompt")
                prox.HoldDuration = 0.5
                prox.ActionText = "Pickup"
                prox.Parent = itemModel
            end

            player.Character.Humanoid:UnequipTools()
        end
    end
end

I must position all the tool parts one by one

maybe use :PivotTo() for the tool as a whole instead of moving the parts one by one?

1 Like

it’s a tool not a model, tools don’t have CFrame

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.