I’m trying to get the group experiences and display them in a list so the user can teleport between games
Server:
-- Server-Side Script (ServerScriptService)
local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local groupIds = {32758679, 16196224} -- Replace these with the actual group IDs
local FetchExperiencesEvent = game.ReplicatedStorage:WaitForChild("FetchExperiencesEvent")
-- Function to fetch experiences for a group
local function fetchExperiencesForGroup(groupId)
local url = "https://games.roproxy.com/v2/groups/" .. groupId .. "/games?sortOrder=Asc&limit=10"
local success, response = pcall(function()
return HttpService:GetAsync(url)
end)
if success then
local data = HttpService:JSONDecode(response)
print(response)
return data.data
else
warn("Failed to fetch experiences for group " .. groupId)
return {}
end
end
-- Function to fetch experiences for all groups and fire the RemoteEvent
local function fetchAllExperiences()
local allExperiences = {}
for _, groupId in ipairs(groupIds) do
local experiences = fetchExperiencesForGroup(groupId)
for _, gameInfo in ipairs(experiences) do
table.insert(allExperiences, gameInfo)
end
end
-- Fire the RemoteEvent with all experiences
FetchExperiencesEvent:FireAllClients(allExperiences)
end
-- Call the function to fetch all experiences
fetchAllExperiences()
Client:
-- Client-Side Script (LocalScript)
local containerFrame = script.Parent
local gameTemplate = game.ReplicatedStorage.GameInfo
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FetchExperiencesEvent = ReplicatedStorage:WaitForChild("FetchExperiencesEvent")
-- Function to clone and set up game template
local function setupGameTemplate(gameInfo)
local newGameTemplate = gameTemplate:Clone()
newGameTemplate.Name = gameInfo.name
newGameTemplate.Message.Text = gameInfo.name
newGameTemplate.ImageLabel.Image = "rbxassetid://" .. tostring(gameInfo.iconImageAssetId)
newGameTemplate.gameId.Value = gameInfo.rootPlaceId
newGameTemplate.Parent = containerFrame
end
-- Event listener for receiving experiences
FetchExperiencesEvent.OnClientEvent:Connect(function(allExperiences)
for _, gameInfo in ipairs(allExperiences) do
setupGameTemplate(gameInfo)
end
end)
But it just displays failed to fetch group experiences