The print signifies that the character is loading in. I think this could be going two ways:
The function repeats for each part of the character loaded in.
The function repeats because of _, v in pairs even though there is 1 player.
while wait(0.4) do
for _,v in pairs(players:GetPlayers()) do
local spawndebounce = true
v.CharacterAdded:Connect(function()
if spawndebounce == true then
v.leaderstats.Deaths.Value += 1
print('overstack')
respawnflash:FireClient(v)
spawndebounce = false
wait(1)
spawndebounce = true
end
end)
end
end
it’s normal because you have started by making the variable true, so it will execute it , and on the rest of the script you set it to false then back to true so it will be looping it non stop
local spawndebounce = true
while wait(0.4) do
for _,v in pairs(players:GetPlayers()) do
v.CharacterAdded:Connect(function()
if spawndebounce == true then
v.leaderstats.Deaths.Value += 1
print('overstack')
respawnflash:FireClient(v)
spawndebounce = false
wait(1)
spawndebounce = true
end
end)
end
end
this is a server script i want the game to update a leaderstat of deaths whenever someone dies putting this outside of the loop would debounce all players
local DebouncedPlayers = {}
while wait(0.4) do
for _,v in pairs(players:GetPlayers()) do
v.CharacterAdded:Connect(function()
if not DebouncedPlayers[v.Name] then
v.leaderstats.Deaths.Value += 1
print('overstack')
respawnflash:FireClient(v)
DebouncedPlayers[v.Name] = v
wait(1)
DebouncedPlayers[v.Name] = nil
end
end)
end
end