Just a little frame for each player that would join the layout when another player joins the server or leaves. So like if a player joins the server the circle of players would grow by making room for the new player, and everyone would be spaced out evenly.
This code makes the player frames go into a circular type of layout. Note that it is a loop, but you can dissect it and try to use it.
function getPlayerCount()
return #(game.Players:GetChildren())
end
function updateList()
local GetPlayers = game.Players:GetPlayers()
local a = getPlayerCount()
local b = 360
local c = 0
local n = b / a
if script.Parent:FindFirstChild("PlayerFrame") then
for _, value in pairs(GetPlayers) do
if script.Parent:FindFirstChild("PlayerFrame") then
script.Parent:FindFirstChild("PlayerFrame"):Destroy()
end
end
end
for _, value in pairs(GetPlayers) do
c = c + n
local uiClone = game.ReplicatedStorage.ProfileGui.PlayerFrame:Clone()
uiClone.Parent = script.Parent
local x = 100 * math.sin(math.rad(c)) -- The 100 is the distance from the center mark
local y = 100 * math.cos(math.rad(c)) -- The 100 is the distance from the center mark
uiClone.Position = UDim2.new(x, 0, y, 0)
end
end
while true do
c = 0
updateList()
wait(5)
end
Your use of FindFirstChild… it scares me. Why are you checking if PlayerFrame exists, 3 times? And the 3rd use of it is useless. I’m assuming the code is wrong and you meant to check each player’s UI instead.
I copied that part of code from a player list Ui that I had saved in file, and didn’t care to mess with it because it worked, very old code from when I started.
Edit: But I do see what you mean, thanks.