-
What do you want to achieve?
I would like there to be a billboardgui that shows this amount visits above the head and for it to be done separately for each player on the server and update the billboardgui -
What is the issue?
I’ve been thinking about how to do it for 2 days now and I’m slowly starting to have enough, that’s why I’m writing here -
What solutions have you tried so far?
roblox dev, robox docs, youtube
Script:
local Players = game:GetService("Players")
local GroupService = game:GetService("GroupService")
local HttpService = game:GetService("HttpService")
local function calculateTotalPlaceVisits(gamesData)
local totalPlaceVisits = 0
for _, game in ipairs(gamesData) do
totalPlaceVisits = totalPlaceVisits + game.placeVisits
end
return totalPlaceVisits
end
Players.PlayerAdded:Connect(function(player) -- Or any event where player can be used
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 owns 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 = calculateTotalPlaceVisits(response.data)
print("Total Place Visits: " .. totalVisits)
end
end
end)