How to check is Player currently playing game or no?

Hello there! I’m working on some game which is based on players’ interaction between each other and want to make something like this:

image

This is from a game called “Adopt Me!”. So basically it shows if player plays this game right now or no. I tried to search some articles about it up, but didn’t find anything about it. Maybe there are something that allows check is player playing right now or no, whatever server they are it.

If you know something about it, please, leave some sources in reply. Have an awesome day! :wink:

3 Likes

There are several ways to go about doing this

You could set a datastore on roblox with all the players that are currently online and look for them (request limits might make that a very bad option)

Another way would be using your own dedicated server to host your own database storing all of the online players and (web)server sided code to sort it all and retrieve the players friendlist online status with a single httprequest (optimal way of doing this imo)

And a third way that im not so sure about is sending a request to the roblox api (using a middle server because you cant send an api request to roblox using roblox studio) to check who on the player friendlist is online and what game theyre playing (it wont work for some cases because of privacy settings)

Edit:
Another way I just remembered is using this
This service will allow you to communicate with all of the servers of your game

2 Likes

There is in fact a way to do this with the lua api I think. I did just just look this up but here we go:

You can use a thing called GetPlayerPlaceInstanceAsync which returns in the player is currently in the games server list. Check out the example code on the api page.

3 Likes

I don’t exactly need friends of player, but how to know what game someone is playing and are they online right now?

This would probably be the best way to go about doing this (if you don’t already have a dedicated server for your game for other uses)
So just ignore my comment :slight_smile:

1 Like

I mean yeah this way means that you dont get to see if a player is “online” on roblox. I guess you could change the wording to make it say “not on the game” and “on the game”

1 Like

if you’re looking to find the status of friends specifically, you’re looking for Players:GetFriendsAsync():

https://developer.roblox.com/en-us/api-reference/function/Players/GetFriendsAsync

there are code samples demonstrating how to use this method at the bottom of the documentation page

(alternatively: Player:GetFriendsOnline)

2 Likes

but how to see what game are they playing right now?

Player:GetFriendsOnline returns a table containing both the place and game (sometimes referred to as job ID) IDs. this allows you to teleport a player directly into the same server

1 Like

This has been answered before

1 Like