-- Enhanced Night Vision and NPC Highlighter (FULLY FIXED PERSISTENCE) local Players = game:GetService("Players") local Lighting = game:GetService("Lighting") local UserInputService = game:GetService("UserInputService") local Workspace = game:GetService("Workspace") local Teams = game:GetService("Teams") local RunService = game:GetService("RunService") local LocalPlayer = Players.LocalPlayer -- GUI Creation local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "EnhancedVisionGui" ScreenGui.ResetOnSpawn = false ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling pcall(function() ScreenGui.Parent = game.CoreGui end) if not ScreenGui.Parent then ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") end local MainFrame = Instance.new("Frame") MainFrame.Size = UDim2.new(0, 180, 0, 40) MainFrame.Position = UDim2.new(0, 10, 0, 10) MainFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40) MainFrame.BorderSizePixel = 0 MainFrame.Active = true MainFrame.Draggable = false MainFrame.Parent = ScreenGui local UICorner = Instance.new("UICorner") UICorner.CornerRadius = UDim.new(0, 8) UICorner.Parent = MainFrame -- Draggable title area local DragArea = Instance.new("Frame") DragArea.Size = UDim2.new(1, 0, 0, 40) DragArea.BackgroundColor3 = Color3.fromRGB(30, 30, 30) DragArea.BorderSizePixel = 0 DragArea.Active = true DragArea.Parent = MainFrame local DragCorner = Instance.new("UICorner") DragCorner.CornerRadius = UDim.new(0, 8) DragCorner.Parent = DragArea local Title = Instance.new("TextLabel") Title.Size = UDim2.new(0.7, 0, 1, 0) Title.Position = UDim2.new(0, 5, 0, 0) Title.BackgroundTransparency = 1 Title.Text = "Enhanced Vision ▼" Title.TextColor3 = Color3.fromRGB(255, 255, 255) Title.Font = Enum.Font.SourceSansBold Title.TextSize = 14 Title.TextXAlignment = Enum.TextXAlignment.Left Title.Parent = DragArea -- Expand/Collapse button local ExpandButton = Instance.new("TextButton") ExpandButton.Size = UDim2.new(0, 30, 0, 30) ExpandButton.Position = UDim2.new(1, -35, 0, 5) ExpandButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60) ExpandButton.BorderSizePixel = 0 ExpandButton.Text = "▼" ExpandButton.TextColor3 = Color3.fromRGB(255, 255, 255) ExpandButton.Font = Enum.Font.SourceSansBold ExpandButton.TextSize = 14 ExpandButton.Parent = DragArea local ExpandCorner = Instance.new("UICorner") ExpandCorner.CornerRadius = UDim.new(0, 5) ExpandCorner.Parent = ExpandButton local ContentFrame = Instance.new("Frame") ContentFrame.Size = UDim2.new(1, 0, 0, 0) ContentFrame.Position = UDim2.new(0, 0, 0, 40) ContentFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50) ContentFrame.BorderSizePixel = 0 ContentFrame.ClipsDescendants = true ContentFrame.Parent = MainFrame local TabButtons = Instance.new("Frame") TabButtons.Size = UDim2.new(1, 0, 0, 30) TabButtons.BackgroundTransparency = 1 TabButtons.Parent = ContentFrame local VisionTab = Instance.new("TextButton") VisionTab.Size = UDim2.new(0.5, 0, 0, 30) VisionTab.BackgroundColor3 = Color3.fromRGB(60, 60, 60) VisionTab.BorderSizePixel = 0 VisionTab.Text = "Vision" VisionTab.TextColor3 = Color3.fromRGB(255, 255, 255) VisionTab.Font = Enum.Font.SourceSans VisionTab.TextSize = 12 VisionTab.Parent = TabButtons local HealthTab = Instance.new("TextButton") HealthTab.Size = UDim2.new(0.5, 0, 0, 30) HealthTab.Position = UDim2.new(0.5, 0, 0, 0) HealthTab.BackgroundColor3 = Color3.fromRGB(40, 40, 40) HealthTab.BorderSizePixel = 0 HealthTab.Text = "Health/Names" HealthTab.TextColor3 = Color3.fromRGB(255, 255, 255) HealthTab.Font = Enum.Font.SourceSans HealthTab.TextSize = 12 HealthTab.Parent = TabButtons local VisionFrame = Instance.new("Frame") VisionFrame.Size = UDim2.new(1, 0, 0, 150) VisionFrame.Position = UDim2.new(0, 0, 0, 30) VisionFrame.BackgroundTransparency = 1 VisionFrame.Visible = true VisionFrame.Parent = ContentFrame local HealthFrame = Instance.new("Frame") HealthFrame.Size = UDim2.new(1, 0, 0, 220) HealthFrame.Position = UDim2.new(0, 0, 0, 30) HealthFrame.BackgroundTransparency = 1 HealthFrame.Visible = false HealthFrame.Parent = ContentFrame -- Helper function to create buttons local function createButton(text, order, parent) local btn = Instance.new("TextButton") btn.Size = UDim2.new(0.9, 0, 0, 25) btn.Position = UDim2.new(0.05, 0, 0, 10 + (order * 30)) btn.BackgroundColor3 = Color3.fromRGB(80, 80, 80) btn.BorderSizePixel = 0 btn.Text = text .. ": OFF" btn.TextColor3 = Color3.fromRGB(255, 255, 255) btn.Font = Enum.Font.SourceSans btn.TextSize = 12 btn.Parent = parent local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 5) corner.Parent = btn return btn end local NightVisionToggle = createButton("Night Vision", 0, VisionFrame) local PlayerHeatToggle = createButton("Player Heat", 1, VisionFrame) local NPCHeatToggle = createButton("NPC Heat", 2, VisionFrame) local PlayerHealthToggle = createButton("Player Health", 0, HealthFrame) local NPCHealthToggle = createButton("NPC Health", 1, HealthFrame) local PlayerNamesToggle = createButton("Player Names", 2, HealthFrame) local NPCNamesToggle = createButton("NPC Names", 3, HealthFrame) local TeamCheckToggle = createButton("Team Check", 4, HealthFrame) -- Status labels local StatusLabelHealth = Instance.new("TextLabel") StatusLabelHealth.Size = UDim2.new(0.9, 0, 0, 40) StatusLabelHealth.Position = UDim2.new(0.05, 0, 0, 160) StatusLabelHealth.BackgroundColor3 = Color3.fromRGB(50, 50, 50) StatusLabelHealth.BorderSizePixel = 0 StatusLabelHealth.Text = "All modes inactive" StatusLabelHealth.TextColor3 = Color3.fromRGB(200, 200, 200) StatusLabelHealth.Font = Enum.Font.SourceSans StatusLabelHealth.TextSize = 10 StatusLabelHealth.TextWrapped = true StatusLabelHealth.Parent = HealthFrame local StatusCornerH = Instance.new("UICorner") StatusCornerH.CornerRadius = UDim.new(0, 5) StatusCornerH.Parent = StatusLabelHealth local StatusLabelVision = Instance.new("TextLabel") StatusLabelVision.Size = UDim2.new(0.9, 0, 0, 40) StatusLabelVision.Position = UDim2.new(0.05, 0, 0, 100) StatusLabelVision.BackgroundColor3 = Color3.fromRGB(50, 50, 50) StatusLabelVision.BorderSizePixel = 0 StatusLabelVision.Text = "All modes inactive" StatusLabelVision.TextColor3 = Color3.fromRGB(200, 200, 200) StatusLabelVision.Font = Enum.Font.SourceSans StatusLabelVision.TextSize = 10 StatusLabelVision.TextWrapped = true StatusLabelVision.Parent = VisionFrame local StatusCornerV = Instance.new("UICorner") StatusCornerV.CornerRadius = UDim.new(0, 5) StatusCornerV.Parent = StatusLabelVision -- State local Settings = { NightVision = false, PlayerHeat = false, NPCHeat = false, PlayerHealth = false, NPCHealth = false, PlayerNames = false, NPCNames = false, TeamCheck = false, GuiExpanded = false } local Cache = { PlayerHighlights = {}, NPCHighlights = {}, PlayerHealthBars = {}, NPCHealthBars = {}, NPCNameTags = {}, OriginalLighting = {}, OriginalAtmosphere = {}, VisionEffects = {}, NPCData = {}, TrackedNPCs = {} } local npcMonitorConnection = nil local playerConnections = {} -- Helper functions local function hasTeams() return #Teams:GetTeams() > 0 end local function isEnemy(player) if not Settings.TeamCheck then return true end if player == LocalPlayer then return false end if not hasTeams() then return true end if not player.Team or not LocalPlayer.Team then return true end return player.Team ~= LocalPlayer.Team end local function isNPC(model) if not model or not model:IsA("Model") then return false end if Players:GetPlayerFromCharacter(model) then return false end local humanoid = model:FindFirstChildOfClass("Humanoid") if not humanoid then return false end if not (model:FindFirstChild("Head") or model:FindFirstChild("HumanoidRootPart")) then return false end return true end -- Night Vision local function enableNightVision() if not Cache.OriginalLighting.Stored then Cache.OriginalLighting = { Ambient = Lighting.Ambient, Brightness = Lighting.Brightness, FogEnd = Lighting.FogEnd, FogStart = Lighting.FogStart, GlobalShadows = Lighting.GlobalShadows, FogColor = Lighting.FogColor, Stored = true } end Lighting.Ambient = Color3.fromRGB(100, 100, 100) Lighting.Brightness = 3 Lighting.FogEnd = 100000 Lighting.FogStart = 0 Lighting.GlobalShadows = false for _, effect in ipairs(Lighting:GetChildren()) do if effect:IsA("Atmosphere") then if not Cache.OriginalAtmosphere.Stored then Cache.OriginalAtmosphere = { Effect = effect, Density = effect.Density, Offset = effect.Offset, Glare = effect.Glare, Haze = effect.Haze, Stored = true } end effect.Density = 0 effect.Offset = 0 effect.Glare = 0 effect.Haze = 0 end end if not Cache.VisionEffects.NightVision then local cc = Instance.new("ColorCorrectionEffect") cc.Name = "NV_CC" cc.TintColor = Color3.fromRGB(0, 255, 0) cc.Saturation = -0.8 cc.Brightness = 0.3 cc.Parent = Lighting Cache.VisionEffects.NightVision = cc end end local function disableNightVision() if Cache.OriginalLighting.Stored then Lighting.Ambient = Cache.OriginalLighting.Ambient Lighting.Brightness = Cache.OriginalLighting.Brightness Lighting.FogEnd = Cache.OriginalLighting.FogEnd Lighting.FogStart = Cache.OriginalLighting.FogStart Lighting.GlobalShadows = Cache.OriginalLighting.GlobalShadows Lighting.FogColor = Cache.OriginalLighting.FogColor end if Cache.OriginalAtmosphere.Stored and Cache.OriginalAtmosphere.Effect then local atm = Cache.OriginalAtmosphere.Effect if atm.Parent then atm.Density = Cache.OriginalAtmosphere.Density atm.Offset = Cache.OriginalAtmosphere.Offset atm.Glare = Cache.OriginalAtmosphere.Glare atm.Haze = Cache.OriginalAtmosphere.Haze end end if Cache.VisionEffects.NightVision then Cache.VisionEffects.NightVision:Destroy() Cache.VisionEffects.NightVision = nil end Cache.OriginalLighting = {} Cache.OriginalAtmosphere = {} end -- Create Highlight with FORCED persistence local function createHighlight(model, color, isNPC) if not model or not model.Parent then return end local existingHL = model:FindFirstChildOfClass("Highlight") if existingHL and existingHL.Name == "ESP_Highlight" then existingHL:Destroy() end local highlight = Instance.new("Highlight") highlight.Name = "ESP_Highlight" highlight.FillColor = color highlight.OutlineColor = color highlight.FillTransparency = 0.5 highlight.OutlineTransparency = 0.2 highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop highlight.Parent = model if isNPC then Cache.NPCHighlights[model] = highlight else Cache.PlayerHighlights[model] = highlight end return highlight end -- Create Health Bar with FORCED persistence local function createHealthBar(character, isNPC, teamColor) if not character or not character.Parent then return end local humanoid = character:FindFirstChildOfClass("Humanoid") if not humanoid then return end local existingHB = character:FindFirstChild("ESP_HealthBar") if existingHB then existingHB:Destroy() end local bb = Instance.new("BillboardGui") bb.Name = "ESP_HealthBar" bb.Size = UDim2.new(4, 0, 0.8, 0) bb.StudsOffset = Vector3.new(0, 3.5, 0) bb.AlwaysOnTop = true bb.Adornee = character:FindFirstChild("Head") or character.PrimaryPart bb.Parent = character local healthText = Instance.new("TextLabel") healthText.Size = UDim2.new(1, 0, 0.5, 0) healthText.BackgroundTransparency = 1 healthText.Text = math.floor(humanoid.Health) .. "/" .. math.floor(humanoid.MaxHealth) healthText.TextColor3 = teamColor or Color3.fromRGB(255, 255, 255) healthText.TextStrokeTransparency = 0 healthText.Font = Enum.Font.SourceSansBold healthText.TextSize = 14 healthText.Parent = bb local frame = Instance.new("Frame") frame.Size = UDim2.new(1, 0, 0.35, 0) frame.Position = UDim2.new(0, 0, 0.55, 0) frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50) frame.BorderSizePixel = 0 frame.Parent = bb local bar = Instance.new("Frame") bar.Size = UDim2.new(math.clamp(humanoid.Health / humanoid.MaxHealth, 0, 1), 0, 1, 0) if teamColor then bar.BackgroundColor3 = teamColor else bar.BackgroundColor3 = isNPC and Color3.fromRGB(255, 100, 0) or Color3.fromRGB(0, 200, 0) end bar.BorderSizePixel = 0 bar.Parent = frame local conn = humanoid.HealthChanged:Connect(function(health) pcall(function() if bar and bar.Parent then local percent = math.clamp(health / humanoid.MaxHealth, 0, 1) bar.Size = UDim2.new(percent, 0, 1, 0) healthText.Text = math.floor(health) .. "/" .. math.floor(humanoid.MaxHealth) if teamColor then bar.BackgroundColor3 = teamColor else if percent > 0.5 then bar.BackgroundColor3 = isNPC and Color3.fromRGB(255, 100, 0) or Color3.fromRGB(0, 200, 0) elseif percent > 0.25 then bar.BackgroundColor3 = Color3.fromRGB(255, 165, 0) else bar.BackgroundColor3 = Color3.fromRGB(255, 0, 0) end end end end) end) if isNPC then Cache.NPCHealthBars[character] = {Gui = bb, Connection = conn} else Cache.PlayerHealthBars[character] = {Gui = bb, Connection = conn} end end -- Create Name Tag with FORCED persistence local function createNameTag(character, isNPC, teamColor) if not character or not character.Parent then return end local existingNT = character:FindFirstChild("ESP_NameTag") if existingNT then existingNT:Destroy() end local bb = Instance.new("BillboardGui") bb.Name = "ESP_NameTag" bb.Size = UDim2.new(0, 100, 0, 40) bb.StudsOffset = Vector3.new(0, 4.5, 0) bb.AlwaysOnTop = true bb.Adornee = character:FindFirstChild("Head") or character.PrimaryPart bb.Parent = character local label = Instance.new("TextLabel") label.Size = UDim2.new(1, 0, 1, 0) label.BackgroundTransparency = 1 label.Text = character.Name if teamColor then label.TextColor3 = teamColor else label.TextColor3 = isNPC and Color3.fromRGB(255, 170, 0) or Color3.fromRGB(255, 255, 255) end label.TextStrokeTransparency = 0 label.Font = Enum.Font.SourceSansBold label.TextSize = 14 label.Parent = bb if isNPC then Cache.NPCNameTags[character] = bb end end -- Apply to player local function applyToPlayer(player) if player == LocalPlayer or not player.Character then return end if not isEnemy(player) then return end local char = player.Character local playerTeamColor = nil if player.Team then playerTeamColor = player.Team.TeamColor.Color end if Settings.PlayerHeat then local color = playerTeamColor or Color3.fromRGB(255, 0, 0) createHighlight(char, color, false) end if Settings.PlayerHealth then createHealthBar(char, false, playerTeamColor) end if Settings.PlayerNames then createNameTag(char, false, playerTeamColor) end end -- Apply to NPC with tracking local function applyToNPC(npc) if not npc or not npc.Parent then return end if not isNPC(npc) then return end Cache.TrackedNPCs[npc] = true if not Cache.NPCData[npc] then Cache.NPCData[npc] = { Connections = {}, LastCheck = tick() } end if Settings.NPCHeat then createHighlight(npc, Color3.fromRGB(255, 100, 0), true) end if Settings.NPCHealth then createHealthBar(npc, true, nil) end if Settings.NPCNames then createNameTag(npc, true, nil) end end -- Remove from player local function removeFromPlayer(player) if not player.Character then return end local char = player.Character if Cache.PlayerHighlights[char] then pcall(function() Cache.PlayerHighlights[char]:Destroy() end) Cache.PlayerHighlights[char] = nil end if Cache.PlayerHealthBars[char] then if Cache.PlayerHealthBars[char].Connection then pcall(function() Cache.PlayerHealthBars[char].Connection:Disconnect() end) end if Cache.PlayerHealthBars[char].Gui then pcall(function() Cache.PlayerHealthBars[char].Gui:Destroy() end) end Cache.PlayerHealthBars[char] = nil end pcall(function() local nameTag = char:FindFirstChild("ESP_NameTag") if nameTag then nameTag:Destroy() end end) end -- Remove from NPC local function removeFromNPC(npc) if Cache.NPCHighlights[npc] then pcall(function() Cache.NPCHighlights[npc]:Destroy() end) Cache.NPCHighlights[npc] = nil end if Cache.NPCHealthBars[npc] then if Cache.NPCHealthBars[npc].Connection then pcall(function() Cache.NPCHealthBars[npc].Connection:Disconnect() end) end if Cache.NPCHealthBars[npc].Gui then pcall(function() Cache.NPCHealthBars[npc].Gui:Destroy() end) end Cache.NPCHealthBars[npc] = nil end if Cache.NPCNameTags[npc] then pcall(function() Cache.NPCNameTags[npc]:Destroy() end) Cache.NPCNameTags[npc] = nil end if Cache.NPCData[npc] then for _, conn in ipairs(Cache.NPCData[npc].Connections) do pcall(function() conn:Disconnect() end) end Cache.NPCData[npc] = nil end end -- Check if any NPC features are enabled local function isNPCFeaturesEnabled() return Settings.NPCHeat or Settings.NPCHealth or Settings.NPCNames end -- AGGRESSIVE NPC Monitor - Checks and reapplies every frame if needed local function startNPCMonitor() if npcMonitorConnection then npcMonitorConnection:Disconnect() end if not isNPCFeaturesEnabled() then return end local lastFullScan = tick() npcMonitorConnection = RunService.Heartbeat:Connect(function() local now = tick() -- Full scan every 3 seconds if now - lastFullScan > 3 then lastFullScan = now for _, obj in ipairs(Workspace:GetDescendants()) do if obj:IsA("Model") and isNPC(obj) then if not Cache.TrackedNPCs[obj] then applyToNPC(obj) end end end end -- Quick check every frame on tracked NPCs for npc, _ in pairs(Cache.TrackedNPCs) do if npc and npc.Parent then -- Verify and reapply if missing if Settings.NPCHeat and not npc:FindFirstChild("ESP_Highlight") then createHighlight(npc, Color3.fromRGB(255, 100, 0), true) end if Settings.NPCHealth and not npc:FindFirstChild("ESP_HealthBar") then createHealthBar(npc, true, nil) end if Settings.NPCNames and not npc:FindFirstChild("ESP_NameTag") then createNameTag(npc, true, nil) end else -- NPC removed Cache.TrackedNPCs[npc] = nil removeFromNPC(npc) end end end) end -- Stop NPC monitoring local function stopNPCMonitor() if npcMonitorConnection then npcMonitorConnection:Disconnect() npcMonitorConnection = nil end end -- Refresh players local function refreshPlayers() for _, player in ipairs(Players:GetPlayers()) do removeFromPlayer(player) if player ~= LocalPlayer and player.Character then applyToPlayer(player) end end end -- Refresh NPCs local function refreshNPCs() for npc in pairs(Cache.TrackedNPCs) do removeFromNPC(npc) end Cache.TrackedNPCs = {} if isNPCFeaturesEnabled() then startNPCMonitor() else stopNPCMonitor() end end -- Update status local function updateStatus() local active = {} for k, v in pairs(Settings) do if v == true and k ~= "GuiExpanded" then table.insert(active, k:gsub("([A-Z])", " %1"):sub(2)) end end local statusText = #active == 0 and "All modes inactive" or table.concat(active, ", ") StatusLabelVision.Text = statusText StatusLabelHealth.Text = statusText end -- Bind button local function bindButton(btn, key, color) btn.MouseButton1Click:Connect(function() Settings[key] = not Settings[key] local baseText = btn.Text:match("(.+):") btn.Text = baseText .. ": " .. (Settings[key] and "ON" or "OFF") btn.BackgroundColor3 = Settings[key] and color or Color3.fromRGB(80, 80, 80) if key == "NightVision" then if Settings[key] then enableNightVision() else disableNightVision() end elseif key:find("Player") or key == "TeamCheck" then refreshPlayers() elseif key:find("NPC") then refreshNPCs() end updateStatus() end) end bindButton(NightVisionToggle, "NightVision", Color3.fromRGB(0, 150, 0)) bindButton(PlayerHeatToggle, "PlayerHeat", Color3.fromRGB(150, 0, 0)) bindButton(NPCHeatToggle, "NPCHeat", Color3.fromRGB(200, 100, 0)) bindButton(PlayerHealthToggle, "PlayerHealth", Color3.fromRGB(0, 150, 0)) bindButton(NPCHealthToggle, "NPCHealth", Color3.fromRGB(200, 100, 0)) bindButton(PlayerNamesToggle, "PlayerNames", Color3.fromRGB(100, 100, 200)) bindButton(NPCNamesToggle, "NPCNames", Color3.fromRGB(200, 150, 50)) bindButton(TeamCheckToggle, "TeamCheck", Color3.fromRGB(0, 100, 200)) -- GUI Controls ExpandButton.MouseButton1Click:Connect(function() Settings.GuiExpanded = not Settings.GuiExpanded if Settings.GuiExpanded then Title.Text = "Enhanced Vision ▲" ExpandButton.Text = "▲" local targetHeight = VisionFrame.Visible and 190 or 270 ContentFrame.Size = UDim2.new(1, 0, 0, targetHeight) MainFrame.Size = UDim2.new(0, 180, 0, 40 + targetHeight) else Title.Text = "Enhanced Vision ▼" ExpandButton.Text = "▼" ContentFrame.Size = UDim2.new(1, 0, 0, 0) MainFrame.Size = UDim2.new(0, 180, 0, 40) end end) -- Tab switching VisionTab.MouseButton1Click:Connect(function() VisionFrame.Visible = true HealthFrame.Visible = false VisionTab.BackgroundColor3 = Color3.fromRGB(60, 60, 60) HealthTab.BackgroundColor3 = Color3.fromRGB(40, 40, 40) if Settings.GuiExpanded then ContentFrame.Size = UDim2.new(1, 0, 0, 190) MainFrame.Size = UDim2.new(0, 180, 0, 230) end end) HealthTab.MouseButton1Click:Connect(function() VisionFrame.Visible = false HealthFrame.Visible = true VisionTab.BackgroundColor3 = Color3.fromRGB(40, 40, 40) HealthTab.BackgroundColor3 = Color3.fromRGB(60, 60, 60) if Settings.GuiExpanded then ContentFrame.Size = UDim2.new(1, 0, 0, 270) MainFrame.Size = UDim2.new(0, 180, 0, 310) end end) -- Dragging local dragging = false local dragInput local dragStart local startPos DragArea.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = input.Position startPos = MainFrame.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) DragArea.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then dragInput = input end end) UserInputService.InputChanged:Connect(function(input) if input == dragInput and dragging then local delta = input.Position - dragStart MainFrame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end) -- Setup player connections local function setupPlayerConnections(player) if player == LocalPlayer then return end if playerConnections[player] then for _, conn in ipairs(playerConnections[player]) do conn:Disconnect() end end playerConnections[player] = {} local charAddedConn = player.CharacterAdded:Connect(function(char) task.wait(0.5) applyToPlayer(player) end) local charRemovingConn = player.CharacterRemoving:Connect(function() removeFromPlayer(player) end) local teamChangedConn = player:GetPropertyChangedSignal("Team"):Connect(function() task.wait(0.1) removeFromPlayer(player) if player.Character then applyToPlayer(player) end end) table.insert(playerConnections[player], charAddedConn) table.insert(playerConnections[player], charRemovingConn) table.insert(playerConnections[player], teamChangedConn) if player.Character then task.defer(function() applyToPlayer(player) end) end end -- Setup players for _, player in ipairs(Players:GetPlayers()) do setupPlayerConnections(player) end Players.PlayerAdded:Connect(function(player) setupPlayerConnections(player) end) Players.PlayerRemoving:Connect(function(player) removeFromPlayer(player) if playerConnections[player] then for _, conn in ipairs(playerConnections[player]) do conn:Disconnect() end playerConnections[player] = nil end end) -- Workspace monitoring for new NPCs Workspace.DescendantAdded:Connect(function(obj) if not isNPCFeaturesEnabled() then return end if obj:IsA("Humanoid") then local model = obj.Parent task.wait(0.2) if model and model.Parent and isNPC(model) and not Cache.TrackedNPCs[model] then applyToNPC(model) end elseif obj:IsA("Model") then task.wait(0.3) if obj.Parent and isNPC(obj) and not Cache.TrackedNPCs[obj] then applyToNPC(obj) end end end) -- Cleanup on GUI destruction ScreenGui.Destroying:Connect(function() stopNPCMonitor() if Settings.NightVision then disableNightVision() end for _, player in ipairs(Players:GetPlayers()) do removeFromPlayer(player) end for npc in pairs(Cache.TrackedNPCs) do removeFromNPC(npc) end for player, connections in pairs(playerConnections) do for _, conn in ipairs(connections) do conn:Disconnect() end end end)