How can I input, for example, epicUsername and get an output of all the users which name matches, even offline users? For example, return an array {epicUsername,epicUsername1,epicUsername7798,epicUsername127318238,etc}?
Thanks in advance
How can I input, for example, epicUsername and get an output of all the users which name matches, even offline users? For example, return an array {epicUsername,epicUsername1,epicUsername7798,epicUsername127318238,etc}?
Thanks in advance
Search for string manipulation or pattern matching on the developer hub. You should find API references and tutorials there…
Sorry, I didn’t make it clear.
Including users offline at the moment
local tab = {}
for i, v in pairs(game.Players:GetChildren()) do
if string.match("epicUsername",v.Name) then
table.insert(tab, v)
end
end
You’d have to use roblox’s API; you’ll have to use this endpoint to search for users. However, you can’t send a request directly to this endpoint from roblox because they don’t allow you to send requests to any of their domain (anything inclusive of roblox.com). You’ll have to use a proxy where you’ll have to set up an external server.
But, you don’t have to do that because a proxy for all of roblox’s API has been set up already: http://rprxy.xyz/. For example, you’d have to send requests to https://users.roblox.com/v1/users/search?keyword=Rare&limit=10 to search players with “Rare” in their name, but now with the proxy, you’d just have to replace roblox.com
with rprxy.xyz
, and you’re good to go:
https://users.rprxy.xyz/v1/users/search?keyword=Rare&limit=10
In studio now, you’ll have to use GetAsync since the API requires you to use the “GET” method and decode it from JSON to make it into a Lua table:
local name = "Rare"
local HttpService = game:GetService("HttpService")
local res = HttpService:GetAsync("https://users.rprxy.xyz/v1/users/search?keyword=" .. name .. "&limit=10"
res = HttpService:JSONDecode(res)