Hi, I was wondering if there is a way to detect a player was last online.
Help is appreciated, thanks.
This chrome extension does it, if you want to do it in a game try searching on google for an api
Alright Thank you! Much appreciated.
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/
The link you sent isn’t working
Oh, thanks much appreciated!!!
So, I have to use HttpService
and use :GetAsync()
to get their last online time?
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.
I don’t know what a proxy is and how I use it
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
Can you please give an example I’m not sure what you mean.
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.
How do I get a proxy node(sorry if this is weird)
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.
Ok, Thank you so much! Much appreciated, thanks again
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:
- Make a PHP file in your webhost file manager
- Get UserID from global variables (we will send that in the link):
$userid = $_GET["userid"];
- then we need to send HTTP request to the endpoint:
$response = http_get("http://api.roblox.com/users/" . $userid . "/onlinestatus/");
- And finally echo that response (aka return the results)
echo $response;
Roblox Lua Side:
- Make a script (not local)
- 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)
- JSONDecode our response because we didn’t in our PHP file
local onlinestatustable = game:GetService("HttpService"):JSONDecode(response)
- And finally pick out the value you want:
print(onlinestatustable.LastOnline)
Thank god I am online. Thank you very very very much!!!
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.
Any help is appreciated thank you!