I’m currently trying to get a user’s Join Date via a Function. However, it always returns “nil” when called. Here’s my code:
local Players = game:GetService("Players")
local cache = {}
local function getUserIdFromUsername(name)
if cache[name] then return cache[name] end
local player = Players:FindFirstChild(name)
if player then
cache[name] = player.UserId
return player.UserId
end
local id
pcall(function ()
id = Players:GetUserIdFromNameAsync(name)
end)
cache[name] = id
return id
end
local id = getUserIdFromUsername(buildername)
local httpservice = game:GetService("HttpService")
local url = "http://rprxy.xyz/users/" ..id.. "/profile"
local html = httpservice:GetAsync(url)
local cut = [[<p class="stat%-title">Join Date</p>%S+<p class="rbx%-lead">(.-)</p>]]
local joindate = html:match(cut);
local joindatetext = tostring(joindate)
return joindatetext
Anybody know of a fix for this? If so, please reply.
Iirc, I don’t believe you can send HttpRequests to Roblox like that. Instead, you should use their account age to get their join data which should be relatively accurate. Here’s a solution I found in a scripting helpers post.
local day = 60 * 60 * 24 -- seconds in a day
game.Players.PlayerAdded:Connect(function(plr)
local tm = os.time() - (day * plr.AccountAge) -- player join date in seconds
local date = os.date("!*t", tm) -- convert seconds to date
print(date.year .. "-" .. date.month .. "-" .. date.day) -- print date
end)
local Players = game:GetService'Players'
local UserId = Players:GetUserIdFromNameAsync'heii_ish'
local HttpService = game:GetService'HttpService'
local Success, Response = pcall(function()
return HttpService:GetAsync("https://users.rprxy.xyz/v1/users/" .. UserId)
end)
if Success then
Response = HttpService:JSONDecode(Response)
print("Join Date:", Response.created)
else
warn(Response)
end