I was messing up with the Roblox HttpService for a while but I can’t get the script to work, it’s supposed to print the username but it instead prints that there was no information/data.
My script is:
local httpService = game:GetService('HttpService')
local url = 'http://users.roblox.com/v1/users/1/'
local function getROBLOXdisplayName()
local get
local information
local username
pcall(function ()
get = httpService:GetAsync(url)
information = httpService:JSONDecode(get)
end)
if not information then
print("Not Information") return false end
if information.displayName == "ROBLOX" then
print("Found DisplayName")
if information.name == "ROBLOX" then
print("Found name in JSON")
username = "ROBLOX"
print('Username from ROBLOX is: '..username)
return true end end return false end
getROBLOXdisplayName()
local success, result = pcall(function()
return Players:GetUserInfosByUserIdsAsync({ 8000 })
end)
if success then
for _, userInfo in ipairs(result) do
print("Id:", userInfo.Id)
print("Username:", userInfo.Username)
print("DisplayName:", userInfo.DisplayName)
end
else
-- an error occurred
end
--> Id: 8000
--> Username: player1
--> DisplayName: player1
I editted the script, I had in my clipboard the other before I used it.
Edit: The script doesn’t works, I am trying to make a GET Request to the roblox api and get the username by there, not in the game.
Other Edit: I didnt add a variable, thats why it didnt work
HTTP (Hypertext Transfer Protocol) relies on TCP (Transmission Control Protocol) to send the messages from one side to the other side (browser-client) and talking about the log saying there’s no data: I, Riley suggest you check the target server’s domain name or IP address and see if there are any typos. Or possibly you need to check your open ports.