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 3 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

[
{
    "Id": 12345678,
    "Username": "user",
    "AvatarUri": "",
    "AvatarFinal": true,
    "IsOnline": true
}
]

{
    "Id": 12345678,
    "Username": "user name"
}

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
3 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.

local http = game:GetService("HttpService")

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

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

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

sorry, thats the best i can do.

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

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

Answer this question