local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local HttpService = game:GetService("HttpService")
local TeleportService = game:GetService("TeleportService")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer

-- Essential Variables
local ESPEnabled = false
local highlights = {}

-- [ UI LIBRARY SETUP ]
local Library = loadstring(game:HttpGetAsync("https://[Log in to view URL]"))()

local Window = Library:Window({
    Title = "NWR's Hub | Rivals",
    SubTitle = "by whoisnwr",
    TabWidth = 160, 
    Size = UDim2.fromOffset(580, 520),
    Acrylic = true, 
    Theme = "Darker",
})

local Tabs = { 
    Main = Window:AddTab({ Title = "Main", Icon = "target" }),
    Settings = Window:AddTab({ Title = "Settings", Icon = "settings" })
}

-- [ CORE LOGIC ]

local function updateHighlight(player)
    if player == LocalPlayer then return end
    
    -- Remove existing highlight to refresh it
    if highlights[player] then
        highlights[player]:Destroy()
        highlights[player] = nil
    end

    if ESPEnabled and player.Character and player.Character.Parent then
        local character = player.Character
        local highlight = Instance.new("Highlight")
        highlight.Name = "NWR_ESP"
        highlight.Parent = character
        highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
        highlight.FillTransparency = 0.5
        highlight.OutlineTransparency = 0
        
        -- Team Detection via Workspace Folder Parent
        -- Checks if the player is in workspace.Characters["Terrorists"] or ["Counter-Terrorists"]
        local playerTeamFolder = character.Parent.Name
        local localTeamFolder = (LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character.Parent.Name or ""

        if playerTeamFolder == localTeamFolder then
            highlight.FillColor = Color3.fromRGB(0, 255, 0)   -- Teammates: Green
            highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
        else
            highlight.FillColor = Color3.fromRGB(255, 0, 0)   -- Enemies: Red
            highlight.OutlineColor = Color3.fromRGB(255, 255, 255)
        end
        
        highlights[player] = highlight
    end
end

-- [ UI COMPONENTS ]

Tabs.Main:AddToggle("ESPToggle", {
    Title = "Player Highlights (ESP)", 
    Default = false,
    Callback = function(Value)
        ESPEnabled = Value
        -- Refresh all players immediately when toggled
        for _, player in ipairs(Players:GetPlayers()) do
            updateHighlight(player)
        end
    end 
})

-- [ EVENT LISTENERS ]

-- Handle players joining and respawning
Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        task.wait(0.5) -- Wait for character to parent to the Team folder
        updateHighlight(player)
    end)
end)

-- Initial check for players already in server
for _, player in ipairs(Players:GetPlayers()) do
    player.CharacterAdded:Connect(function()
        task.wait(0.5)
        updateHighlight(player)
    end)
end

-- Periodic check to update colors if teams switch during a round
task.spawn(function()
    while task.wait(2) do
        if ESPEnabled then
            for _, player in ipairs(Players:GetPlayers()) do
                updateHighlight(player)
            end
        end
    end
end)

Library:Notify({
    Title = "NWR's Hub",
    Content = "Script Loaded Successfully",
    Duration = 5
})

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: