Example , If the player has a LeverHolder, and He clicked on the broken lever, the broken lever will be fix and his level in his inventory will dissapear? can anyone help?
I also tried
script.Parent.ClickDetector.MouseClick:Connect(function() local player = game.Players.LocalPlayer player.Backpack:WaitForChild("Lever"):Destroy() end)
We can simply look inside the player's backpack to that certain instance.
Assuming this is being done through a clickdetector.
part.ClickDetector.MouseClick:Connect(function(plr) if plr.Backpack:FindFirstChild("LeverHolder") then --dostuff end end)
What if this was a Tool? The player could equip it and it would no longer be in the Backpack, now we have to check if it is in the character.
part.ClickDetector.MouseClick:Connect(function(plr) if plr.Backpack:FindFirstChild("LeverHolder") or plr.Character:FindFirstChild("LeverHolder") --dostuff end end)