Hello there,
I have a playerlist UI which shows if your in a group or not, and if you are then it’ll say the group’s name on the playerlist. Basically what’s happening is that it’s only checking to see if your in the group at the end of the list instead of checking through the rest. Does anyone know what I did wrong?
Code
local groups = {
{ id = 3411267, name = "SVEALAND" },
{ id = 3240949, name = "MERCIA" },
{ id = 1246558, name = "NORTHUMBRIA" },
{ id = 3247990, name = "DANELAW" },
{ id = 3493953, name = "EAST ANGLIA" },
{ id = 3418930, name = "DANES" },
{ id = 3416823, name = "NORSE" },
{ id = 3412261, name = "GOTALAND" },
{ id = 3181532, name = "NORRLAND" },
{ id = 4121922, name = "DUBLIN" },
{ id = 1124324, name = "ICELAND" },
{ id = 3458210, name = "KIEVAN RUS" },
{ id = 4121912, name = "THE ISLES" },
{ id = 4121933, name = "THE POWYS" },
{ id = 3778509, name = "DYFED" },
{ id = 3493930, name = "CORNWALLUM" },
{ id = 3269061, name = "ALT CLUT" },
{ id = 3265487, name = "GWYNEDD" },
{ id = 3316962, name = "PICTLAND" },
{ id = 3172503, name = "MUNSTER" },
{ id = 3490619, name = "GLYWYSING" },
{ id = 3406180, name = "ULSTER" },
{ id = 3507435, name = "MEATH" },
{ id = 3406391, name = "CONNACHT" },
{ id = 3413132, name = "LEINSTER" },
{ id = 3414659, name = "BRITTANY" },
{ id = 3779588, name = "MIDDLE FRANKIA" },
{ id = 3419708, name = "WEST FRANKIA" },
{ id = 3421863, name = "EAST FRANKIA" },
{ id = 3421863, name = "MERCENARIES" },
{ id = 3422678, name = "THE CHURCH" },
{ id = 3128836, name = "PAGAN CHURCH" },
{ id = 1245097, name = "WESSEX" },
}
local ld = script.Parent:WaitForChild("Leaderboard")
local list = ld:WaitForChild("List")
--local rank = ld:WaitForChild("Player"):WaitForChild("PlrRank")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local enterfading = false
local leavefading = false
local gui = game:GetService("StarterGui")
gui:SetCoreGuiEnabled("PlayerList",false)
local function update()
-- Get rid of the existing tags
for e,d in pairs(list:GetChildren()) do
d:remove()
end
for i,v in pairs(game.Players:GetChildren()) do
if v ~= nil then
for e,d in pairs(list:GetChildren()) do
d.Position = d.Position + UDim2.new(0,0,0,d.Size.Y.Offset)
end
local tag = ld:WaitForChild("Player"):Clone()
local plrName = tag:WaitForChild("PlrName")
tag.Parent = list
-- Make the name in uppercase letters for charity
plrName.Text = string.upper(v.Name)
-- Set Player's Rank
tag.PlrRank.Text = string.upper(v:GetRoleInGroup(2965628)) -- Change to your group ID
-- Set Player's Group
for _, group in pairs(groups) do
if v:IsInGroup(group.id) then
tag.GrpRank.Text = group.name
else
tag.GrpRank.Text = "NO FACTION"
end
end
tag.GrpRank.Visible = true
-- Set Player's Thumbnail
local content, bool = game.Players:GetUserThumbnailAsync(v.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
tag.ImageLabel.Image = content
tag.Visible = true
tag.MouseEnter:connect(function()
repeat wait() until leavefading == false
enterfading = true
repeat
tag.Brightness.BackgroundTransparency = tag.Brightness.BackgroundTransparency - 0.02
wait()
until tag.Brightness.BackgroundTransparency <= 0.8
tag:FindFirstChild("Brightness").BackgroundTransparency = 0.8
wait(0.2)
enterfading = false
end)
tag.MouseLeave:connect(function()
repeat wait() until enterfading == false
leavefading = true
repeat
tag.Brightness.BackgroundTransparency = tag.Brightness.BackgroundTransparency + 0.02
wait()
until tag.Brightness.BackgroundTransparency >= 1
tag.Brightness.BackgroundTransparency = 1
wait(0.2)
leavefading = false
end)
end
end
list.CanvasSize = UDim2.new(0,0,0,#list:GetChildren()*45) -- Make sure we update the size of the list
end
game.Players.PlayerAdded:connect(update)
mouse.KeyDown:connect(function(key)
if string.lower(key) == "l" then
if ld.Visible then
game.Lighting.Blur.Size = 0
script.Parent:FindFirstChild("Open"):Play()
ld.Visible = not ld.Visible
elseif not ld.Visible then
ld.Visible = true
game.Lighting.Blur.Size = 15
script.Parent:FindFirstChild("Close"):Play()
end
end
end)
update()