I have a inventory with tools in it, how it works is that If you press on a equip button, you equip it, I do this by first deleting everything in your inventory then making a clone of a tool and parenting it to your backpack, however, I get this error/warning? - exception while signaling: The Parent property of Axe is locked, current parent: NULL, new parent
This is especially odd though, because this error only happens if I press they key bind for the tool, which is 1, but when I press the tool in the tool bar with my mouse, I can equip and unequip it.
This is a snippet of the code that is essential to this topic:
if isEquipping == true and isBought == true then
if shopType == "axe" then
dataManager:UnequipTools(player)
dataManager:EquipTool(player,name,true)
for _, v in next, char:GetChildren() do
local tool = v
if v:IsA("Tool") then
if tool:FindFirstChild("axeHandler") then
tool:Destroy()
end
end
end
for _, v in next, player.Backpack:GetChildren() do
local tool = v
if v:FindFirstChild("values") then
if tool:FindFirstChild("axeHandler") then
tool:Destroy()
end
end
end
end
if shopType == "backpack" then
dataManager:UnequipBackpacks(player)
dataManager:EquipBackpack(player,name,true)
for _, v in next, char:GetChildren() do
local backpack = v
if v.Name == "Backpack" and v:IsA("Model") then
backpack:Destroy()
end
end
end
player.PlayerGui:WaitForChild("ScreenGUI"):WaitForChild("buyPrompt"):WaitForChild("interact").Text = "Equipped"
local folder = game.ReplicatedStorage:FindFirstChild(""..shopType.."s")
if folder then
for _, v in next, folder:GetChildren() do
local item = v
if shopType == "axe" then
if v.Name == name then
local clonedTool = item:Clone()
clonedTool.Parent = player.Backpack
char:WaitForChild("Humanoid"):UnequipTools()
char:WaitForChild("Humanoid"):EquipTool(clonedTool)
clonedTool.Name = shopType:lower():gsub("^%l", string.upper)
player.PlayerGui:WaitForChild("ScreenGUI"):WaitForChild("buyPrompt"):WaitForChild("interact").Text = "Equipped"
end
end
Thanks! I also understand that this error I get only happens if you try reparenting a object that is destroyed, but that doesn’t seem to be exactly the case because I destroy everything in my inventory then make a new clone and parent it to my backpack, so the thing in my backpack can’t be destroyed, after all I can still equip it by pressing the tool in the tool bar rather than pressing the keybind.