The Parent property of Product is locked, current parent: NULL, new parent Backpack

So I wanna make a part that when it’s clicked it will give a tool and when it’s clicked again it will take the tool away from the player but I get this error could somebody help?
Here is the script:

local Clone = game.ServerStorage.Product:Clone()
local part = script.Parent

part.MouseClick:Connect(function(player)
	if part.Parent.Transparency == 0 then
		Clone.Parent = player.Backpack
		part.Parent.Transparency = 1
	else
		part.Parent.Transparency = 0
		player.Backpack.Product:Destroy()
	end
end)

Change your code to this:

local part = script.Parent

part.MouseClick:Connect(function(player)
    local Clone = game.ServerStorage.Product:Clone()
	if part.Parent.Transparency == 0 then
		Clone.Parent = player.Backpack
		part.Parent.Transparency = 1
	else
		part.Parent.Transparency = 0
		player.Backpack.Product:Destroy()
	end
end)

You have to make the clone in the mouse click event!

1 Like

I did not know that was the problem Thank You So Much

2 Likes