Hey! I’m trying to make a script that tracks how many mintues a player has been in my game for and posts them to a webhook when they leave. I’m having an error where it only posts the message if the minutes value is 0, meaning if the player leaves before the timer hits 60 seconds. I think there’s an issue with this part of the script:
while secs >= 60 do
secs = secs - 60
mins = mins + 1
end
Because when I look at the live value in game, when it gets to 60 it doesn’t change but it still prints 1 as the minute value. Any help would be appreciated with this, thanks!
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local webhook = "webhook id"
Players.PlayerAdded:Connect(function(plr)
local TimedData
local Time = Instance.new("IntValue")
Time.Name = "Time"
Time.Parent = plr
end)
Players.PlayerRemoving:Connect(function(plr)
local Time = plr:WaitForChild("Time").Value
local secs = Time
local mins = 0
while secs >= 60 do
secs = secs - 60
mins = mins + 1
end
local SendDataV =
{["content"] = "<:GreenzCafe:840350448107257927> **"..plr.Name.."** has joined the cafe for **"..mins.."** minutes!"}
local NewSendDataV = HttpService:JSONEncode(SendDataV)
HttpService:PostAsync(webhook, NewSendDataV)
end)
while wait(1) do
for i,V in pairs(game.Players:GetPlayers()) do
if V:FindFirstChild("Time") and V then
V.Time.Value = V.Time.Value + 1
end
end
end