bin = script.Parent ItemName = "Darkheart" WaitTime = 20 Item = bin:findFirstChild(ItemName) backup = Item:clone() function regen() local regen = backup:clone() regen.Parent = bin end debounce = false function onTaken(property) if (debounce == true) then return end debounce = true if (bin:findFirstChild(ItemName) == nil) then wait(WaitTime) regen() end debounce = false end Item.Changed:connect(onTaken)
Check the comments below, they will help you understand what happened
bin = script.Parent ItemName = "Darkheart" WaitTime = 20 Item = bin:FindFirstChild(ItemName) -- add a capital F to all :FindFirstChild() s backup = Item:Clone() -- add a capital C to all :Clone() s function regen() local regen = backup:Clone() regen.Parent = bin end debounce = false local function onTaken(prop) if debounce then return end debounce = true if bin:FindFirstChild(ItemName) == nil then coroutine.wrap(function() wait(WaitTime) regen() -- regenerate tool debounce = false end)() end end Item.Changed:Connect(onTaken) -- RBXScriptSignal:connect is deprecated, use RBXScriptSignal:Connect
Hope this works! If this does work for you, please mark this as one! Thats all, Metatable out!