After creating the code, it still doesn't work even though the url and API are correct, can you help me to turn it around somehow?
local Timers = {}
Players.PlayerAdded:Connect(function(Player)
Timers[Player.UserId] = {
Start = os.time()
}
end)
Players.PlayerRemoving:Connect(function(Player)
Timers[Player.UserId].End = os.time()
local TotalTime = Timers[Player.UserId].End - Timers[Player.UserId].Start
end)
local HttpService = game:GetService("HttpService")
local BASE_URL = "url"
local API_KEY = "1234567890"
local function sendMessage(message)
local url = string.format("%s", BASE_URL, message)
local headers = {["X-API-Key"] = API_KEY}
local success, response = pcall(function()
return HttpService:PostAsync(url, "", Enum.HttpContentType.ApplicationJson, false, headers)
end)
if success then
local result = HttpService:JSONDecode(response)
if result.success then
print(result)
else
warn("API Error:", result.error or "Unknown error")
end
else
warn("Request failed:", response)
end
end
str(TotalTime)```
** You are now Level 1! **