Get players game status

So im trying to get this status from the player using the roblox Api. but can’t find anything on the devforums about it.

image
image

if anyone has a way to get these statuses from the player:

“In Game (playing wich game)”, “In studio (developing wich game)”, “on website”, “offline”, “banned”

4 Likes

You can only do this for a player’s friends using Player:GetFriendsOnline(), it returns a dictionary of players with their location type. Player | Documentation - Roblox Creator Hub

6 Likes

but whats the difference between “webpage” and “mobile website”, “studio” and “team create”, “mobile ingame” and “ingame”.

what icons should be displayed with these locationtypes?

and does this only work with friends? or also with other players

2 Likes

They are what they say they are.

1 Like

but there aren’t any icons for the “xbox” and “teamcreate” locationtypes

and would the mobile versions just display the normal “ingame” and “website” icon (blue profile, and green game icon)

1 Like

What about somehow get random friend of that player and then use Player:GetFriendsOnline() like @bytesleuth suggested, but use that friend to get your status?

2 Likes

so you mean, i first get a friend of that person. then use the :GetFriendOnline() to get that players status?

1 Like

There’s an external api you can use to get the presence of a list of userids.
https://presence.roblox.com/docs/index.html#!/Presence/post_v1_presence_users

This is what each userPresenceType number means:

0 - “Offline”
1 - “Online”
2 - “In Game”
3 - “In Studio”

Note: you will need a proxy to access this api.

I tried to do script but to do GetFriendsOnline() you need player object so it looks like it’s dead end

i tried using roproxy but i keep getting this error “{“errors”:[{“code”:0,“message”:“MethodNotAllowed”}]}”

i used this url “https://presence.roproxy.com/v1/presence/users/544088422

1 Like

You need to send it with a cookie or logged in on an account i don’t know why

1 Like

Got it to work using the /v1/presence/users endpoint instead, no authentication required:

--Enable HttpService through game settings
--If the place isn't published run game.HttpService.HttpEnabled = true in command bar
local HttpService = game:GetService("HttpService")

type presence = {lastLocation: string, lastOnline: string, userId: number, userPresenceType: number, name: string?}

local url = "https://presence.roproxy.com/v1/presence/users"
local body = HttpService:JSONEncode({userIds = {544088422}})

local names = {"Offline", "Online", "In Game", "In Studio"}

local response = HttpService:PostAsync(url, body)
local presence: presence = HttpService:JSONDecode(response).userPresences[1]

presence.name = names[presence.userPresenceType+1]

print(presence, presence.name)

This endpoint accepts and can return multiple user statuses at once, so instead of making multiple calls at once, you can just send multiple userIds at once(the maximum userIds at once is 50).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.