So basically I'm trying to make an activity log where it can log how much time a user spends on the game and send it to a webhook to Discord but I'm meeting some problems and I can't exactly pinpoint where because it's happening in the PlayerRemoving event.
Can someone check this over and/or tell me how I can look for errors in the event? note: all links are removed for privacy issues although they all work
local HttpService = game:GetService("HttpService") local store = {} game.Players.PlayerAdded:connect(function(player) if HttpService:JSONDecode(HttpService:GetAsync('https://a-link-here.com'))["data"]["rank"] > 18 then store[player.UserId] = tick() print(store[player.UserId]) end end) game.Players.PlayerRemoving:connect(function(player) if HttpService:JSONDecode(HttpService:GetAsync('https://a-link-here.com'))["data"]["rank"] > 18 then if store[player.UserId] ~= nil then print(store[player.UserId]) local amountoftime = HttpService:JSONDecode(HttpService:PostAsync('https://a-link-here.com', {timestamp1 = store[player.UserId], timestamp2 = tick()}))["data"]["diff"] print(amountoftime) local embeds = { {title = "**ACTIVITY LOGS**", description = player.Name.." has joined the game for "..amountoftime.. ".", color = 3665674, footer = {text = "X | Activity Logs", icon_url = "https://a-link-here.com"}} } local array = { username = "Activity Logs", embeds = embeds, -- the embed } local Data = { webhookurl='https://a-link-here.com', array=array } game:GetService("HttpService"):PostAsync('https://a-link-here.com', game:GetService"HttpService":JSONEncode(Data), 0) end end end)
Thanks in advance