So I've made a time counter that would after the player left give the time to a discord webhook and handle it there. Its a serverscript. The script works good with 1 person but it doesn't work at all with 2+ players.
local Http = game:GetService("HttpService")
local DiscordUr = "[REDACTED]"
game.Players.PlayerAdded:Connect(function(plr)
player = plr
local lead = Instance.new("Folder")
lead.Name = "leaderstats"
lead.Parent = plr
timeon = Instance.new("IntValue")
timeon.Name = "Time"
timeon.Parent = lead
end)
local CountingRoutine = coroutine.create(function()
while wait(1) do
print(player.leaderstats.Time.Value)
player.leaderstats.Time.Value += 1
end
end)
coroutine.resume(CountingRoutine)
game.Players.PlayerRemoving:Connect(function(plr)
local timeoff = timeon.Value
local timecut = timeoff / 60
print(timecut)
if timecut >= 1 then
local encode = Http:JSONEncode({content = timecut,username = plr.Name})
Http:PostAsync(DiscordUr,encode)
else
local encode = Http:JSONEncode({content = timeoff, username = plr.Name})
Http:PostAsync(DiscordUr,encode)
end
end)

3 comments
the answer is probably right, but you didnt give any response as to what was wrong, or what needed to be fixed.
^ hello this is me the guy who asked for the fix. And yea I agree with the comment above / below (I don't know how the comment placement works here)
^ Update: When 2 ppl are in the game and one person leave the bot doesn't send anything