If the user is above a certain rank, their overhead shows name, rank, and a staff emoji
If the user is below that rank, the overhead shows name, rank, and kill count
Script:
local Storage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local overhead = Storage:FindFirstChild("OverheadGuiObject")
Players.PlayerAdded:Connect(function(player)
-- RANK AND NAME TEXTX
player.CharacterAppearanceLoaded:Connect(function(Character)
local overheadClone = overhead:Clone()
overheadClone:FindFirstChild("Name").Text = player.Name
local success1,result1 = pcall(function()
return player:GetRoleInGroup(5127121)
end)
if success1 then
overheadClone.Rank.Text = result1
end
-- KILLS OR STAFF TEXT
if player:GetRoleInGroup(5127121) <= 255 then
player.leaderstats.Kills.Changed:Connect(function()
overheadClone.Kills.Text = "🔪".. player.leaderstats.Kills.Value
end)
elseif player:GetRoleInGroup(5127121) >= 255 then
overheadClone.Kills.Visible = false
overheadClone.Staff.Visible = true
end
overheadClone.Parent = Character:FindFirstChild("Head")
end)
end)
Issue & Note
The script was working before I added the if statement to give the staff emoji
It looks like you’re using GetRoleInGroup instead of GetRankInGroup. Swap them out and it should work. Also you’re using <= which means “less than or equal to”, so the elseif will never go through. Just < should be used instead. Then with the elseif, only == is needed as there is no rank above 255 (but that’s not really important in this case).
Also as a little fun fact, the reason there’s only 255 group ranks is because there are 256 combinations of bits in a byte. 0-255 is 256 numbers, so a user’s rank can be saved with only one byte. Same goes for rgb color, but with 3 bytes (1 for each color).
local Storage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local overhead = Storage:FindFirstChild("OverheadGuiObject")
Players.PlayerAdded:Connect(function(player)
-- RANK AND NAME TEXTX
player.CharacterAppearanceLoaded:Connect(function(Character)
local overheadClone = overhead:Clone()
overheadClone:FindFirstChild("Name").Text = player.Name
local success1,result1 = pcall(function()
return player:GetRoleInGroup(5127121)
end)
if success1 then
overheadClone.Rank.Text = result1
end
-- KILLS OR STAFF TEXT
local success2,result2 = pcall(function()
return player:GetRankInGroup(5127121)
end)
if success2 then
if result2 <= 255 then
player.leaderstats.Kills.Changed:Connect(function()
overheadClone.Kills.Text = "🔪".. player.leaderstats.Kills.Value
end)
elseif result2 >= 255 then
overheadClone.Kills.Visible = false
overheadClone.Staff.Visible = true
end
end
overheadClone.Parent = Character:FindFirstChild("Head")
end)
end)