Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

HTTP Request Errors in Game no matter what?

script.Parent.MouseButton1Click:connect(function()
	local username = script.Parent.Parent.TextBox.Text
	local userid = game.Players:GetUserIdFromNameAsync(username)
	local info = game:GetService("HttpService"):GetAsync("https://api.rprxy.xyz/users/" .. userid .. "/OnlineStatus/")
	script.Parent.Parent.TextLabel.Text = info
end)

That is the code, I made sure that the website was still active, and it is

Website Proof - http://api.rprxy.xyz/users/53248936/OnlineStatus

I'm trying to make a similar game to Alexrocks911's Check a Roblox User's "Last Online" Information

Link to the original: https://www.roblox.com/games/2120256007/Check-a-Roblox-Users-Last-Online-Information

Error: https://prnt.sc/opr8vj

What should I do to fix this? HTTP requests are enabled, and I've tried in both Studio and in game to no avail.

Thanks!

2 comments

0

Do you have HTTP requests enabled?

0

"HTTP requests are enabled" - "Do YoU have HttP ReqUestS enAbleD???/"

1 answer

✓ Accepted answer

You cannot do this in a LocalScript. You have to fire a remote event in ReplicatedStorage, and then handle that event using a Script inside of the ServerScriptService.

Example ServerScriptService script:

game.ReplicatedStorage.GetPlayerInfo.OnServerEvent:Connect(function(player, username, label) -- First variable is always player.
    	local userid = game.Players:GetUserIdFromNameAsync(username);
   	local info = game:GetService("HttpService"):GetAsync("https://api.rprxy.xyz/users/" .. userid .. "/OnlineStatus/");

    	label.Text = info;
end);

Then you can call that in the local script by doing:

local username = script.Parent.Parent.TextBox.Text; -- The username
local targetlabel = script.Parent.Parent.TextLabel; -- The text label that should get the text modified.

game.ReplicatedStorage.GetPlayerInfo:FireServer(username, targetlabel); -- Fire the event on the server, which will cause the code inside of the ServerScriptService to run. As you may have noticed, you do NOT include the first 'player' variable here. It gets passed automatically.

2 comments

0

(Put a RemoteEvent object named GetPlayerInfo in ReplicatedStorage)

0

You're welcome...

This discussion is preserved as it was. New answers, comments, and votes are closed.