local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local ROLE_COLORS = { Crewmate = Color3.fromRGB(0, 255, 0), Imposter = Color3.fromRGB(255, 0, 0), Neutral = Color3.fromRGB(0, 170, 255) } local tagsEnabled = true local connections = {} local function cleanup() for _, connection in ipairs(connections) do if connection then connection:Disconnect() end end connections = {} for _, player in ipairs(Players:GetPlayers()) do if player.Character then local torso = player.Character:FindFirstChild("UpperTorso") or player.Character:FindFirstChild("Torso") if torso then local tag = torso:FindFirstChild("RoleTag") if tag then tag:Destroy() end end end end end local function attachTag(player, character) if not tagsEnabled then return end local torso = character:FindFirstChild("UpperTorso") or character:FindFirstChild("Torso") if not torso then return end local old = torso:FindFirstChild("RoleTag") if old then old:Destroy() end local billboard = Instance.new("BillboardGui") billboard.Name = "RoleTag" billboard.Parent = torso billboard.Adornee = torso billboard.Size = UDim2.new(5, 0, 2, 0) billboard.StudsOffset = Vector3.new(0, 2.5, 0) billboard.AlwaysOnTop = true billboard.MaxDistance = 150 local subText = Instance.new("TextLabel") subText.Name = "SubRoleText" subText.Parent = billboard subText.BackgroundTransparency = 1 subText.Font = Enum.Font.GothamBold subText.TextScaled = true subText.TextStrokeTransparency = 0.25 subText.Size = UDim2.new(1, 0, 0.35, 0) subText.Position = UDim2.new(0, 0, -0.05, 0) subText.Text = "" local roleText = Instance.new("TextLabel") roleText.Name = "RoleText" roleText.Parent = billboard roleText.BackgroundTransparency = 1 roleText.Font = Enum.Font.GothamBold roleText.TextScaled = true roleText.TextStrokeTransparency = 0.25 roleText.Size = UDim2.new(1, 0, 0.6, 0) roleText.Position = UDim2.new(0, 0, 0.35, 0) roleText.Text = "" local function update() if not tagsEnabled then if billboard and billboard.Parent then billboard:Destroy() end return end local ps = player:FindFirstChild("PublicStates") if not ps then return end local roleVal = ps:FindFirstChild("Role") local subRoleVal = ps:FindFirstChild("SubRole") if roleVal and roleVal.Value ~= "" then roleText.Text = roleVal.Value roleText.TextColor3 = ROLE_COLORS[roleVal.Value] or Color3.new(1, 1, 1) else roleText.Text = "" end if subRoleVal and subRoleVal.Value ~= "" then subText.Text = subRoleVal.Value subText.TextColor3 = roleText.TextColor3 else subText.Text = "" end end local ps = player:WaitForChild("PublicStates", 5) if ps then local function setupValueListener(value) if value and value:IsA("StringValue") then local conn = value.Changed:Connect(update) table.insert(connections, conn) end end for _, v in ipairs(ps:GetChildren()) do setupValueListener(v) end local childAddedConn = ps.ChildAdded:Connect(function(v) setupValueListener(v) update() end) table.insert(connections, childAddedConn) end update() end local function setupPlayer(player) local charAddedConn = player.CharacterAdded:Connect(function(char) attachTag(player, char) end) table.insert(connections, charAddedConn) if player.Character then attachTag(player, player.Character) end end local function toggleTags() tagsEnabled = not tagsEnabled if tagsEnabled then print("Role tags: ENABLED") for _, player in ipairs(Players:GetPlayers()) do if player.Character then attachTag(player, player.Character) end end else print("Role tags: DISABLED") for _, player in ipairs(Players:GetPlayers()) do if player.Character then local torso = player.Character:FindFirstChild("UpperTorso") or player.Character:FindFirstChild("Torso") if torso then local tag = torso:FindFirstChild("RoleTag") if tag then tag:Destroy() end end end end end end local function initialize() cleanup() for _, player in ipairs(Players:GetPlayers()) do setupPlayer(player) end local playerAddedConn = Players.PlayerAdded:Connect(function(player) setupPlayer(player) end) table.insert(connections, playerAddedConn) local inputConn inputConn = UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.G then toggleTags() end end) table.insert(connections, inputConn) print("Role tag script initialized. Press G to toggle tags on/off.") end -- Re-execution setup local function setupReexecution() local reexecConn = Players.PlayerAdded:Connect(function(newPlayer) task.wait(1) initialize() print("Script re-executed for new player:", newPlayer.Name) end) table.insert(connections, reexecConn) end initialize() setupReexecution() local cleanupConn = RunService.Heartbeat:Connect(function() end) table.insert(connections, cleanupConn) return { Toggle = toggleTags, Cleanup = cleanup, Initialize = initialize }