Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there anyway to detect whether a player is online?

Asked by 4 years ago

Is there any way to detect whether a player is online? I have search a lot trying to find anything about anything. I have found a few things but they don't work, and or don't do what I want.

I have found a few things like https://api.roblox.com/users/USERID/onlinestatus/ but the page doesn't exist anymore.

I know some scripting but I don't even know where to start with this, all I have for a slight idea is

01[
02{
03    "Id": 12345678,
04    "Username": "user",
05    "AvatarUri": "",
06    "AvatarFinal": true,
07    "IsOnline": true
08}
09]
10 
11{
12    "Id": 12345678,
13    "Username": "user name"
14}

But it returns with errors and such. And I get something working, is there any way to make it perform a function? like delete or make a part or model.

2 answers

Log in to vote
0
Answered by
Hafrew 16
4 years ago

there was a question like this WAY backin 2014 when roblox didnt have good security and stored the data of your player on a website(but this api is probaly destoryed) you can try this but it might not work.

01local http = game:GetService("HttpService")
02 
03game.Players.PlayerAdded:connect(function(plr)
04    plr.Chatted:connect(function(msg)
05        if msg:lower():sub(1,7) == "status/" then
06            local id = tonumber(msg:sub(8)) --Get the ID after the "/" in "status/"
07            if id ~= nil then --If the ID doesn't return nil after being converted to a number then continue.
08                local status = http:GetAsync("http://apiroblox.netne.net/GetUserStatus.php?id="..id) --Get online status of the player from the ID.
09                local m = Instance.new("Message", game.Workspace)
10                m.Text = "Status of player ID "..id..": "..tostring(status)
11            end--if theres any error delete this end
12        end
13    end)
14end)

if that doesnt work you can only see the status of your friends.

1local Players = game:GetService("Players")
2 local player = Players.LocalPlayer
3local onlineFriends = player:GetFriendsOnline(200)--max players
4 for i, friend in pairs(onlineFriends) do
5    print(friend.UserName)
6end

sorry, thats the best i can do.

0
Ok, I will check sometime soon. I will get back to you, thanks! Student20986 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Now, i'm not the greatest but you could use the :WaitForChild method, take my answer lightly though.

Answer this question