So, I have made my own VIP BillBoardGui system. I have used Player:GetRankInGroup and it works fine. The only thing that I need, is I want to add multiple ranks to my if statement. Is there any way to do this and if so how? I will leave a photo below of the script.
Make GroupID variable a table, and insert Group Id’s of your choice in there.
And then on PlayerAdded, go through the table, and add a if statement for specific Group Id’s, and do whatever for them.
Use a table/dictionary and generalize it. There’s no need to have a big if elseif elseif else chain if you can do a for loop to iterate over a table. You could do something like:
local groups = {
[groupId]=rankNumber,
[groupId2]=rankNumber2,
[groupId3]=rankNumber3
}
replacing the ids with their actual ids then you can:
for gId, rId in pairs(groups) do
if player:GetRankInGroup(gId) == rId then
-- ... code here
break
end
end
local BillBoardGUI = game:GetService("ServerStorage"):WaitForChild("VIPOverHeadUI")
local GroupID = {8123401,0} -- 0 is a temporary second groupid, for an example.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
for _,id in next,GroupID do
if id = 8123401 then
if player:GetRankInGroup(id) == 100 then -- Copy and pasted this part.
local clonedgui = BillBoardGUI:Clone()
clonedgui.TextLabel.Text = "VIP"
clonedgui.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
end
end
end
end)
end)
You don’t need to clone the gui to someone many times, if they’re vip, they’re vip so break is required. Second it only checks each groupId to it’s respective rankId so there is no worry about group ids and rank ids messing up
If you mean for each group with a different RankId, then yes that if statement is needed.
If it’s for one group, then stick to the code you’ve started with.
If you want it for groups, but with the same RankId, then maybe.
I guess steven was right, oops.
Well, in that case, this is your solution.
local BillBoardGUI = game:GetService("ServerStorage"):WaitForChild("VIPOverHeadUI")
local GroupID = 8123401
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if player:GetRankInGroup(GroupID) == 100 then
local clonedgui = BillBoardGUI:Clone()
clonedgui.TextLabel.Text = "VIP"
clonedgui.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
end
if player:GetRankInGroup(GroupID) == 100 then -- Copy and paste, but change the number.
local clonedgui = BillBoardGUI:Clone()
clonedgui.TextLabel.Text = "VIP"
clonedgui.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
end
end)