local HttpService = game:GetService("HttpService")
local MainGui = script.Parent
local TextButton = MainGui.TextButton
local Players = game:GetService("Players")
TextButton.MouseButton1Up:Connect(function()
local TextBoxID = MainGui.TextBox.Text
local UsernameWeb = "https://api.rprxy.xyz/users/"..TextBoxID
local function printUsername()
local response
local data
pcall(function()
response = HttpService:GetAsync(UsernameWeb)
data = HttpService:JSONDecode(response)
end)
if not data then return false end
if data.Id == (TextBoxID) then
print(data.Username)
end
end
end)
My script should work as follows:
User enters ID into text box, presses enter. Script looks up the ID through a proxy and prints a username, it’s not doing anything, even giving an error.
edit: This is a localscript, not sure if that makes a difference.
With this, still not getting a single response from it…
local HttpService = game:GetService("HttpService")
local MainGui = script.Parent
local TextButton = MainGui.TextButton
local Players = game:GetService("Players")
TextButton.MouseButton1Up:Connect(function()
local TextBoxID = MainGui.TextBox.Text
local UsernameWeb = "https://api.rprxy.xyz/users/"..(TextBoxID)
local function printUsername()
local response
local data
pcall(function()
response = HttpService:GetAsync(UsernameWeb)
data = HttpService:JSONDecode(response)
end)
if not data then return false end
local IdString = tostring(data.Id)
if IdString == (TextBoxID) then
print(data.Username)
end
end
printUsername()
end)
You can’t use HttpService from a LocalScript. It can only be used on the server. You need to relay the request through a RemoteEvent or RemoteFunction.
Edit: Here’s some completely untested code I’ve just written on my phone that should allow you to proxy the request with a ModuleScript:
ReplicatedStorage.ClientHttp
local Http = game:GetService("HttpService")
local Module = {}
local GetAsyncRemote = Instance.new("RemoteFunction")
function Module.GetAsync(...)
if script:IsA("LocalScript") then
return GetAsyncRemote:InvokeServer(...)
else
return Http:GetAsync(...)
end
end
GetAsyncRemote.OnServerInvoke = function(Player, ...)
return Module.GetAsync(...)
end
return Module
Use like so:
local HttpProxy = require(game:GetService("ReplicatedStorage").ClientHttp)
local response = HttpProxy.GetAsync("example.com/abcdefg")
That may or may not work but I’m not at my PC right now to create a full-fledged solution or test it.