RAP Player in overhead gui

Hello everyone, at the moment I am creating a game that is related to the roblox economy - it shows the robux rate in different real currencies. I have a problem with displaying the player’s RAP. On this forum I could not find the answer to my question, I tried several implementation methods but still nothing worked for me. I hope you can help me with this.
The main problem is that I need to get information from the proxy api in the local environment (for display in the overhead), and for this I tried to use remote events, but without success
(for an example of work, I did not connect to the overhead header change, but made a simple output to the console)
image

Main script (1)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Name = "RemoveEvent"
remoteEvent.Parent = ReplicatedStorage

remoteEvent.OnServerEvent:Connect(function(player)
	local userId = player.UserId

	local url = "https://inventory.roproxy.com/v1/users/" .. userId .. "/assets/collectibles?assetType=8&limit=100&sortOrder=Asc"
	local totalSum = 0

	local success, response = pcall(function()
		return HttpService:GetAsync(url)
	end)

	if success then
		local jsonData = HttpService:JSONDecode(response)
		for _, item in pairs(jsonData.data) do
			totalSum = totalSum + item.recentAveragePrice
		end
		remoteEvent:FireClient(player, totalSum)
	else
		warn("Failed to fetch data from Roblox inventory API")
	end
end)

LocalScript for get UserId (2)

local player = game.Players.LocalPlayer
local userId = player.UserId

local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

remoteEvent.OnClientEvent:Connect(function(total)
    print("recentAveragePrice: " .. total)
end)

remoteEvent:FireServer(userId)
1 Like

so what are you using the client script to do?

sorry, this is an old version of the local script
now I’ll update to the one I’m using

Ye but what are you using the local script to do, what is it actual purpose?

I wrote on the script what it is for - to display information about the player, namely User ID

why you not doing this on the server?

anyway what error or problem are you getting from the server? and what does total print?

The problem I have is that I don’t even know what the error is, output just not showing errors with this scripts

nvm, im just change structure of scripts and their work

Localscript

local player = game.Players.LocalPlayer
local remoteEvent = game.ReplicatedStorage.RemoteEvent_UserId

remoteEvent:FireServer(player.UserId)

Script

...
local remoteEvent2 = game.ReplicatedStorage.RemoteEvent
local HttpService = game:GetService("HttpService")

remoteEvent2.OnServerEvent:Connect(function(player)
	local userId = player.UserId

	local url = "https://inventory.roproxy.com/v1/users/".. userId .."/assets/collectibles?limit=100&sortOrder=Asc"
	local totalSum = 0

	local success, response = pcall(function()
		return HttpService:GetAsync(url)
	end)

	if success then
		local jsonData = HttpService:JSONDecode(response)
		for _, item in pairs(jsonData.data) do
			totalSum = totalSum + item.recentAveragePrice
		end
		print("RAP:".. totalSum)
	else
		warn("Error!")
	end
end)
...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.