GetJoinDate function returning "nil" each time called

Hello,

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.

Thanks,
p0s_0

1 Like

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)
2 Likes

How would I do this with a player that isn’t in-game though?

Nevermind that, you can use this endpoint, but you have to format the timestamp
https://users.roblox.com/docs#!/Users/get_v1_users_userId

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
2 Likes