So I have these two scripts here. Once the purchase next stage script is ran, it resets the character to the next spawn and then it resets the character again after it runs down the respawn time. How should I add a debounce to this so it does not reset the character twice?
local plrs = game.Players
plrs.CharacterAutoLoads = false
local respawnTime = 10
plrs.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:FindFirstChild("Humanoid").Died:Connect(function()
plr.PlayerGui.RespawnGui.Background.RespawnTime.Text = "Respawning in " .. respawnTime .. " seconds..."
plr.PlayerGui.RespawnGui.Background.Visible = true
for i = respawnTime, 0, -1 do
plr.PlayerGui.RespawnGui.Background.RespawnTime.Text = "Respawning in " .. i .. " seconds..."
wait(1)
end
plr.PlayerGui.RespawnGui.Background.Visible = false
plr:LoadCharacter()
end)
end)
plr:LoadCharacter()
end)
local Market = game:GetService("MarketplaceService")
Market.ProcessReceipt = function(receipt)
if receipt.ProductId == 1306306067 then
local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
player:LoadCharacter()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end