I have a overhead gui that works fine, but I’ve made it so if a player owns a badge it will show a text saying “early tester” but it only shows if the player dies (sometimes but rarely it will show without dying)
Let me also add that it’s in a place connected to a game (the game is the main menu and you select maps which is the places)
Here is the OverheadGui Script V
local Players = game:GetService("Players")
local rankInformation = require(script.RankInformation)
local connections = {}
local overHeadTemplate = script.OverheadGui
Players.PlayerAdded:Connect(function (player)
connections[player] = player.CharacterAdded:Connect(function (character)
local newOverhead = overHeadTemplate:Clone()
newOverhead.PlayerName.Text = player.Name
for _, info in pairs (rankInformation) do
local isPlayerInDivision = player:IsInGroup(info.groupId)
if isPlayerInDivision then
newOverhead.Group.Text = info.name
newOverhead.Group.TextColor3 = info.color
newOverhead.Group.Visible = true
newOverhead.Rank.Text = player:GetRoleInGroup(info.groupId)
newOverhead.Rank.Visible = true
end
end
character:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
newOverhead.Parent = character:WaitForChild("HumanoidRootPart")
end)
end)
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local badgeID = 2124845563 -- Change this to your badge ID
local connections = {}
local overHeadTemplate = script.OverheadGui
local function onPlayerAdded(player)
-- Check if the player has the badge
local success, hasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeID)
end)
-- If there's an error, issue a warning and exit the function
if not success then
warn("Error while checking if player has badge!")
return
end
if hasBadge then
overHeadTemplate.Tester.Visible = true -- this shows the text
end
end
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(function (player)
if connections[player] then
connections[player]:Disconnect()
connections[player] = nil
end
end)
Here is the RankInformation Module script
return {
{
name = "Zentryte",
color = Color3.fromRGB(0, 170, 255),
groupId = 3371398
},
{
name = "name",
color = Color3.fromRGB(255, 0, 0),
groupId = 0
}
}
Please let me not I did not make this script cause I’m basic at scripting lol not the greatest but learning.
I used this video for the over head gui-> Rank Overhead GUI - ROBLOX - YouTube
then I used this to help me with showing the text - > BadgeService:UserHasBadgeAsync
just strange why it wont always show when the player joins only when they die it shows?
Maybe there is a way to instantly kill the player and instantly spawn them back when they join and it wont kill them again? only when they join idk
thx!