Is there a way to detect when a player was last online?

Hi, I was wondering if there is a way to detect a player was last online.
Help is appreciated, thanks.

7 Likes

This chrome extension does it, if you want to do it in a game try searching on google for an api

2 Likes

It’s an API endpoint. Having trouble finding it though when I look at api.roblox.com.

3 Likes

Alright Thank you! Much appreciated.

2 Likes

If you would want to do this in game you will need a proxy because HttpService doesn’t let you send any requests to any of ROBLOX’s api endpoints due to security reasons.

If you are looking to do offsite networking then this is the endpoint you should use: http://api.roblox.com/users/(userid)/onlinestatus/

1 Like

The link you sent isn’t working

1 Like

You have to fill in (userid) yourself
Eg: http://api.roblox.com/users/1/onlinestatus/

1 Like

Oh, thanks much appreciated!!!

1 Like

So, I have to use HttpService and use :GetAsync() to get their last online time?

1 Like

Yes but as I told you in my previous reply HttpService will not let you send requests to ROBLOX endpoints. The solution for this is using a proxy to send the request from their own network.

1 Like

I don’t know what a proxy is and how I use it

1 Like

A proxy is basically a node that acts as a retriever on behalf of a client requesting a resource.

In your case you’ll need a proxy to send a request to the api endpoint because ROBLOX servers don’t let you send requests to ROBLOX hosts

1 Like

Can you please give an example I’m not sure what you mean.

1 Like

Instead of directly sending the request from the ROBLOX server, you will basically ask a proxy node to send the request for you and return the data.

That’s basically a proxy in a nutshell.

1 Like

How do I get a proxy node(sorry if this is weird)

1 Like

If you are familiar with backend service languages like python, javascript (node), etc… and already have hosting it will be easy to make a proxy server but if you are new you could watch a tutorial, one thing I recommend for free hosting is heroku, it allows you to run node applications for free and easily.

1 Like

Ok, Thank you so much! Much appreciated, thanks again

1 Like

I know I’m 18 days late to this but another alternative to setting up your own server is using 000webhost or award space (I personally use award space because 000webhost wasn’t doing the job). You can host a PHP file which will send a request to the Roblox Endpoint. I will show an example and I’m assuming you know nothing about PHP.

Server Side:

  1. Make a PHP file in your webhost file manager
  2. Get UserID from global variables (we will send that in the link):
$userid = $_GET["userid"];
  1. then we need to send HTTP request to the endpoint:
$response = http_get("http://api.roblox.com/users/" . $userid . "/onlinestatus/");
  1. And finally echo that response (aka return the results)
echo $response;

Roblox Lua Side:

  1. Make a script (not local)
  2. Request our “proxy” server:
local userid = -- You will have to get the userid with remote events. Ill leave that up to you
local URL = "www.example.com/myphp.php?userid="..userid
local response = game:GetService("HttpService"):GetAsync(URL)
  1. JSONDecode our response because we didn’t in our PHP file
local onlinestatustable = game:GetService("HttpService"):JSONDecode(response)
  1. And finally pick out the value you want:
print(onlinestatustable.LastOnline)
19 Likes

Thank god I am online. Thank you very very very much!!!

2 Likes

Hi! I’ve used this as a template using the same services. Thank you it really helped me out! One question I’ve tried this a couple of times before and it worked flawless! but now I keep getting the same error back "Can’t parse JSON " Could you maybe help me? I’ve tried searching online for this without any result.

php file

Roblox Script


Website blurred out*

Any help is appreciated thank you!