Keep tag after player dies

How to make the player’s tag remain after he dies?

local tagPlayerIDs = {485680559, 1}

function addPlayerTag(player)
    local gui = Instance.new("BillboardGui")
    gui.Name = "PlayerTag"
    gui.Parent = player.Character.Head
    gui.Adornee = player.Character.Head
    gui.MaxDistance = 30
    gui.Size = UDim2.new(2, 0, 2, 0)
    gui.StudsOffset = Vector3.new(0, 3, 0)

    local text = Instance.new("TextLabel")
    text.Text = "Mod"
    text.Font = Enum.Font.Ubuntu
    text.TextColor3 = Color3.fromRGB(93, 0, 255)
    text.Size = UDim2.new(1, 0, 1, 0)
    text.FontSize = Enum.FontSize.Size24
    text.Position = UDim2.new(0, 0, 0.5, 0)
    text.BackgroundTransparency = 1
    text.Parent = gui
end

function onPlayerRespawned(player)
    wait(3)
    if table.find(tagPlayerIDs, player.UserId) then
        addPlayerTag(player)
    end
end

function onPlayerEntered(player)
    player.CharacterAdded:Connect(function()
        onPlayerRespawned(player)
    end)
    onPlayerRespawned(player)
end

game.Players.PlayerAdded:Connect(onPlayerEntered)

for _, player in ipairs(game.Players:GetPlayers()) do
    onPlayerEntered(player)
end
local tagPlayerIDs = {485680559, 1}
local playerTags = {} -- To store player tags
function addPlayerTag(player)
    local existingTag = playerTags[player]
    
    -- Check if there's an existing tag and remove it
    if existingTag then
        existingTag:Destroy()
    end

    local gui = Instance.new("BillboardGui")
    gui.Name = "PlayerTag"
    gui.Parent = player.Character.Head
function onPlayerDied(player)
    local existingTag = playerTags[player]

    -- Check if there's an existing tag and remove it
    if existingTag then
        existingTag:Destroy()
        playerTags[player] = nil
    end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.