Billboardgui showing this number of overhead

  1. 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

  2. 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

  3. 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)
2 Likes
Players.PlayerAdded:Connect(function(player)
  local billboard = Instance.new("BillBoardGui")
  local textlabel = Instance.new("TextLabel")
  ... (Customize the appearence, position, color, etc.)

  (Insert optional part here)

  ... (rest of the code)
end)

Optional part (Updates at after certain cooldown):

local cooldown = 60 -- seconds
task.spawn(function()
  while task.wait() do
    textlabel.Text = string.format("Total Visits: %s", tostring(calculateTotalPlaceVisits(data)))
    task.wait(cooldown)
  end
end)

Correct position for code snipets should be moved little bit, but probably this is what you are looking for.

2 Likes

I’ll explain the logic, in a server script, you want to connect a function to the playeradded event, attach the billboard gui to the players head and replace the text with the number of visits a player has, you can track this by incrementing a variable within their datastore that tracks how many times they’ve visited (make the variable start at 0 and += 1 that variable when PlayerAdded is fired, or make it a default visit count of 1 and increment it on PlayerRemoved).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.