:
-
What do you want to achieve?
The problem is that I am thinking how to optimally update these billboard gui every 5 minutes and make them appear above my head because currently they disappear and do not appear at all -
What is the issue?
Thoughts on how to do it -
What solutions have you tried so far?
Roblox docs, yt
SCRIPT:
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local GroupService = game:GetService("GroupService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function fetchTotalVisits(playerId)
local player = Players:GetPlayerByUserId(playerId)
local requestLink = "https://games.roproxy.com/v2/users/" .. playerId .. "/games"
local response = HttpService:GetAsync(requestLink)
local totalPlaceVisits = 0
local tableResponse = HttpService:JSONDecode(response)
for _, gameInfo in pairs(tableResponse.data) do
totalPlaceVisits = totalPlaceVisits + gameInfo.placeVisits
end
local PlayerBillboard = ReplicatedStorage:FindFirstChild("PlayerBillboard"):Clone()
PlayerBillboard.Parent = player.Character and player.Character:FindFirstChild("Head")
PlayerBillboard.PlayerVisits.Text = "Player Visits: " .. totalPlaceVisits
print(player.DisplayName.. "| Total Player Visits:" ..totalPlaceVisits)
return totalPlaceVisits
end
local function fetchTotalVisitsGroup(gamesData)
local totalPlaceVisits = 0
for _, game in ipairs(gamesData) do
totalPlaceVisits = totalPlaceVisits + game.placeVisits
end
return totalPlaceVisits
end
Players.PlayerAdded:Connect(function(player)
local totalVisits = fetchTotalVisits(player.UserId)
local success, groups = pcall(function()
return GroupService:GetGroupsAsync(player.UserId)
end)
if not success then
warn("Failed to fetch groups for player: " .. player.Name)
return
end
for _, group in ipairs(groups) do
if group.Rank == 255 then
print(player.DisplayName .. "| Group: " .. group.Name .. " (ID: " .. group.Id .. ")")
local endpoint = "https://games.roproxy.com/v2/groups/" .. group.Id .. "/gamesV2?accessFilter=2&limit=100"
local response = HttpService:JSONDecode(HttpService:GetAsync(endpoint))
local totalVisits = fetchTotalVisitsGroup(response.data)
local GroupBillboard = ReplicatedStorage:FindFirstChild("GroupBillboard"):Clone()
GroupBillboard.Parent = player.Character and player.Character:FindFirstChild("Head")
GroupBillboard.GroupVisits.Text = "Group Visits: " .. totalVisits
print(player.DisplayName .. "| Total Group Visits: " .. totalVisits)
end
end
end)