Hello! Recently I got this api code for my plugin from a very great and supportive devforum member! I was wondering how to implement it to show on a ui? Also possible to make a button called use and gets the badge Id and put it in a script.
API:
-- Variables:
local badges = {}
local httpService = game:GetService("HttpService")
local placeId = game.PlaceId
-- Check to see if place is published?
if placeId ~= 0 then
-- Attempt to make a http request to my roblox proxy
local success,response = pcall(function()
return httpService:JSONDecode(httpService:GetAsync(("https://rbx-badge.glitch.me/game/%s"):format(placeId)))
end)
-- See if it responded and has a valid response
if success and response then
if response.success then -- Everything went well!
badges = response.badges
else -- Something went wrong on the server
warn("Error fetching badges internally - " .. response.message)
end
else -- Something errored on Roblox's side
warn("Error getting badges - " .. response)
end
end
for _,badge in pairs(badges) do --> Loop through badges
print(badge.name) --> Badge name
print(badge.id) --> Badge id
print(badge.description) --> Badge description
print(badge.imageId) --> Badge image
print(badge.enabled) --> Is it enabled for use?
end
Have you made UI’s before now?
If not please do a search for information about making one.
I did a quick search of “roblox making a UI” and got loads of information back.
Please give it a try and if you need help then show us what you have made so far.
Otherwise show us what you have so far.
You can simply Send this information from the server on you’re client with RemoteEvent:FireClient then From the client you simply set the GUI
Ex. Label.Text = Data.badge.name
or you can use a RemoteFunction you would require the data from the client, the server will return the data and you you can set the gui with the data given
I assume the API is server-sided because it makes HTTP requests. Therefore if the UI is client-sided(being run by a LocalScript) you have to use a remote function to request data from the server script(view documentation pages to deep further into remote functions and how they work). After the data request gets sent, the server should validate the request before making any actual API HTTP calls(for example rate limit a player, blacklist a group of users, etc). If the data isn’t validated on the server script exploiters will be able to spam requests causing in-game HTTP limits which will affect other in-game players.