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)
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)