RAP GUI not loading rap

GUI:image

Script:

local HttpService = game:GetService("HttpService")
local plr = game.Players.LocalPlayer

local UserId = plr.UserId
local Endpoint =  "https://inventory.rprxy.xyz/v1/users/%d/assets/collectibles"

local Success, Result, Response
local Count = 0

repeat
	Success, Result = pcall(HttpService.GetAsync, HttpService, Endpoint:format(UserId))
	Count += 1
	wait(0.25)
until Success or Count > 5


if Success then
	Response = HttpService:JSONDecode(Result)
	local TotalRap = 0
	for i, Asset in pairs(Response.data) do
		if Asset then
			TotalRap += Asset.recentAveragePrice
		else
			TotalRap = 0
		end
	end
	script.Parent.Text = TotalRap
end

It doesn’t error at all. What am I doing wrong?

1 Like

What’s it supposed to do? What’s a “RAP GUI”?

No idea if this is the issue but the text being changed doesn’t occur inside the loop.

Try putting the
script.Parent.Text = TotalRap
inside the for loop.

2 Likes

supposed to show the RAP of a user. RAP is the robux worth of all the person’s limiteds.

It sets the “TotalRap” variable to the text circled.

You can’t make HTTP requests from the client.

Your pcall is hiding that error from you :slight_smile:

3 Likes

I’m not very experienced in scripting, but I believe what may be happening is that the script can’t read what the number value is for the recent Average Price. That and/or it needs the value “recent” to be defined in some way, how recent it should look for.

By client, do you mean in studio or from the script?

Like from a LocalScript

1 Like

Move your code from a localscript to a regular script and make a RemoteEvent so that you can calculate the RAP value and send it to the client for them to handle.

3 Likes

Ah I see, so they may need to create another script to find the information where it then sends the information over to the specific script that activated it. And possibly creating a script line to create one of the information finding scripts to avoid all the traffic from all the other activation requests from messing up the information, if that’s needed, or if it’s possible, since I don’t know that local client scripts can create server scripts, unless one were to send a request to a reagular server script where that reagular script then create that new script. I’m going to just continue on rambling now I realize, since with what I described would all lead to it just continuously making new scripts.

But a script to collect that information then send it back would in theory work.

No need for all that machinery, @itsLevande is right (although I think a RemoteFunction would work better here)

You may wanna read Bindable Events and Functions | Documentation - Roblox Creator Hub :slight_smile:

2 Likes

Lol, I will

Thank you :slightly_smiling_face: