This commit is contained in:
listik committed 2026-11-29 15:49:17 +03:00
commit a85391509d
211 files changed
+28903

No files matched your search

+339
View File
@@ -0,0 +1,339 @@
--!strict
-- LocalScript in StarterPlayer > StarterPlayerScripts.
-- Goggles for the local player, off by default:
-- N (gamepad Y, mobile "NV") - night vision: green, amplified light, scanlines, noise
-- T (gamepad X, mobile "TH") - thermal: cold grey-blue world, living things glow white-hot
-- Press the same key again to switch the goggles off; press the other key to switch mode.
--
-- Thermal shows every Model with a Humanoid (players, NPCs, animals) plus anything
-- tagged "Hot" with CollectionService (campfires, engines...). Roblox draws at most
-- 31 Highlights at once.
local CollectionService = game:GetService("CollectionService")
local ContextActionService = game:GetService("ContextActionService")
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
if not game:IsLoaded() then
game.Loaded:Wait()
end
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui") :: PlayerGui
---------------------------------------------------------------------
-- Settings
---------------------------------------------------------------------
type ModeConfig = {
ambient: Color3,
outdoorAmbient: Color3,
exposure: number,
saturation: number,
tint: Color3,
contrast: number,
brightness: number,
labelText: string,
labelColor: Color3,
}
local NIGHT_VISION: ModeConfig = {
ambient = Color3.fromRGB(105, 105, 105),
outdoorAmbient = Color3.fromRGB(125, 125, 125),
exposure = 1.2,
saturation = -1, -- grayscale first...
tint = Color3.fromRGB(90, 255, 110), -- ...then tint green
contrast = 0.35,
brightness = 0.05,
labelText = "NV ●",
labelColor = Color3.fromRGB(120, 255, 130),
}
local THERMAL: ModeConfig = {
ambient = Color3.fromRGB(130, 130, 130),
outdoorAmbient = Color3.fromRGB(150, 150, 150),
exposure = 1.2,
saturation = -1,
tint = Color3.fromRGB(150, 170, 215), -- cold background
contrast = 0.1,
brightness = -0.02,
labelText = "THERMAL ●",
labelColor = Color3.fromRGB(255, 170, 60),
}
local HOT_TAG = "Hot"
local HEAT_FILL = Color3.fromRGB(255, 245, 230)
local HEAT_OUTLINE = Color3.fromRGB(255, 255, 255)
local NOISE_AMPLITUDE = 0.025 -- per-frame brightness flicker
local POWER_UP_TIME = 0.35 -- seconds of white flash when switching on
local POWER_UP_FLASH = 0.8
local SCANLINE_COUNT = 180
local SCANLINE_TRANSPARENCY = 0.85
---------------------------------------------------------------------
-- Post-processing effects (local to this client)
---------------------------------------------------------------------
local colorCorrection = Instance.new("ColorCorrectionEffect")
colorCorrection.Name = "GogglesColor"
colorCorrection.Enabled = false
colorCorrection.Parent = Lighting
local bloom = Instance.new("BloomEffect")
bloom.Name = "GogglesBloom"
bloom.Intensity = 1.2
bloom.Size = 30
bloom.Threshold = 0.85
bloom.Enabled = false
bloom.Parent = Lighting
local blur = Instance.new("BlurEffect")
blur.Name = "GogglesBlur"
blur.Size = 2
blur.Enabled = false
blur.Parent = Lighting
---------------------------------------------------------------------
-- Screen overlay: vignette, scanlines, label
---------------------------------------------------------------------
local overlay = Instance.new("ScreenGui")
overlay.Name = "GogglesOverlay"
overlay.IgnoreGuiInset = true
overlay.ResetOnSpawn = false
overlay.DisplayOrder = -10 -- under the rest of the HUD
overlay.Enabled = false
local function makeVignetteEdge(size: UDim2, position: UDim2, rotation: number)
local edge = Instance.new("Frame")
edge.Size = size
edge.Position = position
edge.BackgroundColor3 = Color3.new(0, 0, 0)
edge.BorderSizePixel = 0
edge.Parent = overlay
local gradient = Instance.new("UIGradient")
gradient.Rotation = rotation
gradient.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 0.05),
NumberSequenceKeypoint.new(0.6, 0.75),
NumberSequenceKeypoint.new(1, 1),
})
gradient.Parent = edge
end
makeVignetteEdge(UDim2.fromScale(0.25, 1), UDim2.fromScale(0, 0), 0) -- left
makeVignetteEdge(UDim2.fromScale(0.25, 1), UDim2.fromScale(0.75, 0), 180) -- right
makeVignetteEdge(UDim2.fromScale(1, 0.25), UDim2.fromScale(0, 0), 90) -- top
makeVignetteEdge(UDim2.fromScale(1, 0.25), UDim2.fromScale(0, 0.75), 270) -- bottom
local scanlines = Instance.new("Frame")
scanlines.Name = "Scanlines"
scanlines.Size = UDim2.fromScale(1, 1)
scanlines.BackgroundTransparency = 1
scanlines.Parent = overlay
for i = 0, SCANLINE_COUNT - 1 do
local line = Instance.new("Frame")
line.Size = UDim2.new(1, 0, 0, 1)
line.Position = UDim2.fromScale(0, i / SCANLINE_COUNT)
line.BackgroundColor3 = Color3.new(0, 0, 0)
line.BackgroundTransparency = SCANLINE_TRANSPARENCY
line.BorderSizePixel = 0
line.Parent = scanlines
end
local label = Instance.new("TextLabel")
label.Name = "Label"
label.AnchorPoint = Vector2.new(1, 0)
label.Position = UDim2.new(1, -24, 0, 48)
label.Size = UDim2.fromOffset(160, 24)
label.BackgroundTransparency = 1
label.Font = Enum.Font.Code
label.TextSize = 20
label.TextXAlignment = Enum.TextXAlignment.Right
label.Parent = overlay
overlay.Parent = playerGui
---------------------------------------------------------------------
-- Thermal: highlight warm bodies
---------------------------------------------------------------------
local heatFolder = Instance.new("Folder")
heatFolder.Name = "ThermalHighlights"
heatFolder.Parent = workspace -- created by the client, so only this player sees it
local highlights: { [Instance]: Highlight } = {}
local heatConnections: { RBXScriptConnection } = {}
local function removeHeat(target: Instance)
local highlight = highlights[target]
if highlight then
highlights[target] = nil
highlight:Destroy()
end
end
local function addHeat(target: Instance)
if highlights[target] or target == player.Character then
return
end
if not target:IsDescendantOf(workspace) then
return
end
local highlight = Instance.new("Highlight")
highlight.Adornee = target
highlight.FillColor = HEAT_FILL
highlight.FillTransparency = 0
highlight.OutlineColor = HEAT_OUTLINE
highlight.OutlineTransparency = 0.2
highlight.DepthMode = Enum.HighlightDepthMode.Occluded -- no seeing through walls
highlight.Parent = heatFolder
highlights[target] = highlight
local ancestryConnection: RBXScriptConnection
ancestryConnection = target.AncestryChanged:Connect(function()
if not target:IsDescendantOf(workspace) then
ancestryConnection:Disconnect()
removeHeat(target)
end
end)
table.insert(heatConnections, ancestryConnection)
end
local function onWorkspaceDescendant(descendant: Instance)
if descendant:IsA("Humanoid") then
local model = descendant.Parent
if model and model:IsA("Model") then
addHeat(model)
end
end
end
local function startHeatTracking()
for _, descendant in workspace:GetDescendants() do
onWorkspaceDescendant(descendant)
end
for _, tagged in CollectionService:GetTagged(HOT_TAG) do
addHeat(tagged)
end
table.insert(heatConnections, workspace.DescendantAdded:Connect(onWorkspaceDescendant))
table.insert(heatConnections, CollectionService:GetInstanceAddedSignal(HOT_TAG):Connect(addHeat))
table.insert(heatConnections, CollectionService:GetInstanceRemovedSignal(HOT_TAG):Connect(removeHeat))
end
local function stopHeatTracking()
for _, connection in heatConnections do
connection:Disconnect()
end
table.clear(heatConnections)
for target in highlights do
removeHeat(target)
end
end
---------------------------------------------------------------------
-- Mode switching
---------------------------------------------------------------------
type Mode = "Off" | "NightVision" | "Thermal"
type LightingSnapshot = {
Ambient: Color3,
OutdoorAmbient: Color3,
ExposureCompensation: number,
}
local mode: Mode = "Off"
local baseBrightness = 0
local enabledAt = 0
local savedLighting: LightingSnapshot? = nil
local renderConnection: RBXScriptConnection? = nil
local function onRenderStep()
local flash = math.max(0, 1 - (os.clock() - enabledAt) / POWER_UP_TIME)
local noise = (math.random() * 2 - 1) * NOISE_AMPLITUDE
colorCorrection.Brightness = baseBrightness + flash * POWER_UP_FLASH + noise
end
local function setMode(newMode: Mode)
if newMode == mode then
return
end
local oldMode = mode
mode = newMode
if oldMode == "Thermal" then
stopHeatTracking()
end
if newMode == "Off" then
if renderConnection then
renderConnection:Disconnect()
renderConnection = nil
end
local saved = savedLighting
if saved then
Lighting.Ambient = saved.Ambient
Lighting.OutdoorAmbient = saved.OutdoorAmbient
Lighting.ExposureCompensation = saved.ExposureCompensation
savedLighting = nil
end
colorCorrection.Enabled = false
bloom.Enabled = false
blur.Enabled = false
overlay.Enabled = false
return
end
if oldMode == "Off" then
-- Remember the real night lighting so we can restore it.
savedLighting = {
Ambient = Lighting.Ambient,
OutdoorAmbient = Lighting.OutdoorAmbient,
ExposureCompensation = Lighting.ExposureCompensation,
}
renderConnection = RunService.RenderStepped:Connect(onRenderStep)
end
local config = if newMode == "Thermal" then THERMAL else NIGHT_VISION
-- Client-side Lighting changes only affect this player.
Lighting.Ambient = config.ambient
Lighting.OutdoorAmbient = config.outdoorAmbient
Lighting.ExposureCompensation = config.exposure
colorCorrection.Saturation = config.saturation
colorCorrection.TintColor = config.tint
colorCorrection.Contrast = config.contrast
baseBrightness = config.brightness
label.Text = config.labelText
label.TextColor3 = config.labelColor
enabledAt = os.clock()
colorCorrection.Enabled = true
bloom.Enabled = true
blur.Enabled = true
overlay.Enabled = true
if newMode == "Thermal" then
startHeatTracking()
end
end
local function bindModeKey(actionName: string, target: Mode, title: string, ...: Enum.KeyCode)
ContextActionService:BindAction(
actionName,
function(_name: string, state: Enum.UserInputState, _input: InputObject): Enum.ContextActionResult?
if state == Enum.UserInputState.Begin then
setMode(if mode == target then "Off" else target)
return Enum.ContextActionResult.Sink
end
return Enum.ContextActionResult.Pass
end,
true, -- on-screen button on mobile
...
)
ContextActionService:SetTitle(actionName, title)
end
bindModeKey("ToggleNightVision", "NightVision", "NV", Enum.KeyCode.N, Enum.KeyCode.ButtonY)
bindModeKey("ToggleThermal", "Thermal", "TH", Enum.KeyCode.T, Enum.KeyCode.ButtonX)