Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

So after this, my sword only spawns 3 times now. I want it to spawn infinitely. What's going on?

Asked by 3 years ago
bin = script.Parent

ItemName = "Darkheart" 
WaitTime = 5 


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)

1 answer

Log in to vote
0
Answered by 3 years ago

There is a easier way to do this

game.Players.PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(char)
-- do the clone script 
    end
end)
Ad

Answer this question