optimize this roblox lua code for better performance and less laggy gameplay/lag

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local function CreateNameTag(Player)
    if Player.Character and not Player.Character:FindFirstChild("NameTag") then
        local billboardGui = Instance.new("BillboardGui")
        billboardGui.Name = "NameTag"
        billboardGui.Size = UDim2.new(0, 100, 0, 50)
        billboardGui.StudsOffset = Vector3.new(0, 2, 0)
        billboardGui.Adornee = Player.Character:FindFirstChild("Head") or Player.Character:FindFirstChildWhichIsA("BasePart")
        billboardGui.AlwaysOnTop = true
        billboardGui.Parent = Player.Character

        local textLabel = Instance.new("TextLabel")
        textLabel.Size = UDim2.new(1, 0, 1, 0)
        textLabel.BackgroundTransparency = 1
        textLabel.Text = Player.Name
        textLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White color for the text
        textLabel.TextStrokeTransparency = 0 -- Add a stroke for better visibility
        textLabel.TextSize = 10 -- Set a fixed text size to avoid overly large text
        textLabel.TextWrapped = true -- Ensure text does not overflow
        textLabel.Parent = billboardGui
    end
end

local function CreateHighlight(Player)
    if Player ~= Players.LocalPlayer and Player.Character and not Player.Character:FindFirstChild("Highlight") then
        local highlight = Instance.new("Highlight", Player.Character)
        CreateNameTag(Player)
    end
end

local function UpdateHighlight(Player, HighlightColor)
    local character = Player.Character
    if Player ~= Players.LocalPlayer and character then
        local highlight = character:FindFirstChild("Highlight")
        if highlight then
            highlight.FillColor = HighlightColor
        end
    end
end

local function ApplyChams()
    local LocalPlayer = Players.LocalPlayer
    local roles = ReplicatedStorage:FindFirstChild("GetPlayerData", true):InvokeServer()

    local Murderer, Sheriff, Hero

    for i, v in pairs(roles) do
        if v.Role == "Murderer" then
            Murderer = i
        elseif v.Role == 'Sheriff' then
            Sheriff = i
        elseif v.Role == 'Hero' then
            Hero = i
        end
    end

    for _, Player in pairs(Players:GetPlayers()) do
        CreateHighlight(Player)

        if Player.Name == Sheriff then
            UpdateHighlight(Player, Color3.fromRGB(0, 0, 255)) -- Blue for Sheriff
        elseif Player.Backpack:FindFirstChild("Gun") or (Player.Character and Player.Character:FindFirstChild("Gun")) then
            UpdateHighlight(Player, Color3.fromRGB(0, 0, 255)) -- Blue for players with Gun
        elseif Player.Name == Murderer then
            UpdateHighlight(Player, Color3.fromRGB(255, 0, 0)) -- Red for Murderer
        elseif Player.Name == Hero and not roles[Sheriff].Killed and not roles[Sheriff].Dead then
            UpdateHighlight(Player, Color3.fromRGB(255, 250, 0)) -- Yellow for Hero if Sheriff is dead
        else
            UpdateHighlight(Player, Color3.fromRGB(0, 255, 0)) -- Green for Innocent
        end
    end
end

local function OnCharacterAdded(Player)
    CreateHighlight(Player)
end

for _, v in pairs(Players:GetPlayers()) do
    if v ~= Players.LocalPlayer then
        CreateHighlight(v)
        v.CharacterAdded:Connect(function()
            OnCharacterAdded(v)
        end)
    end
end

Players.PlayerAdded:Connect(function(v)
    if v ~= Players.LocalPlayer then
        CreateHighlight(v)
        v.CharacterAdded:Connect(function()
            OnCharacterAdded(v)
        end)
    end
end)

-- Gun Drop ESP
RunService.RenderStepped:Connect(function()
    local gunDrop = workspace:FindFirstChild("GunDrop")
    if gunDrop and not gunDrop:FindFirstChild("MM2MDG") then
        local hl = Instance.new("Highlight")
        hl.Parent = gunDrop
        hl.FillTransparency = 0
        hl.OutlineTransparency = 0
        hl.OutlineColor = Color3.fromRGB(0, 255, 0)
        hl.FillColor = Color3.fromRGB(255, 180, 29)
        hl.Name = "MM2MDG"
    end
end)

while true do
    ApplyChams()
    wait(1) -- Update chams every second
end