Загрузка данных


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local Lighting = game:GetService("Lighting")
local Players = game:GetService("Players")

local GameConfig = require(ReplicatedStorage:WaitForChild("GameConfig"))
local soundEvent = GameConfig.GetRemoteEvent("MakeNoiseEvent")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

--------------------------------------------------------------------------------
-- 1. НАСТРОЙКА АТМОСФЕРЫ (ТЕМНОТА И ТУМАН В РЕМСТРОЕ)
--------------------------------------------------------------------------------
Lighting.ClockTime = 0 -- Полночь
Lighting.Brightness = 0
Lighting.OutdoorAmbient = Color3.fromRGB(10, 10, 15)
Lighting.FogEnd = 60
Lighting.FogColor = Color3.fromRGB(5, 5, 5)

--------------------------------------------------------------------------------
-- 2. МОБИЛЬНЫЙ / КЛАВИАТУРНЫЙ ФОНАРИК
--------------------------------------------------------------------------------
local flashlight = Instance.new("SpotLight")
flashlight.Brightness = 4
flashlight.Range = 40
flashlight.Angle = 60
flashlight.Enabled = false

local hrp = character:WaitForChild("HumanoidRootPart")
flashlight.Parent = hrp

-- Включение/выключение фонарика на клавишу 'F'
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	
	if input.KeyCode == Enum.KeyCode.F then
		flashlight.Enabled = not flashlight.Enabled
		-- Включение фонарика издает тихий шум
		soundEvent:FireServer(hrp.Position)
	end
end)

--------------------------------------------------------------------------------
-- 3. СОЗДАНИЕ ИНТЕРФЕЙСА (UI) И ИНДИКАТОРА ШУМА
--------------------------------------------------------------------------------
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "RemStroyUI"
screenGui.Parent = playerGui

local hintLabel = Instance.new("TextLabel")
hintLabel.Size = UDim2.new(0, 300, 0, 50)
hintLabel.Position = UDim2.new(0.5, -150, 0.8, 0)
hintLabel.BackgroundTransparency = 0.5
hintLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
hintLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
hintLabel.TextSize = 18
hintLabel.Text = "[F] — Включить фонарик | Остерегайтесь шума!"
hintLabel.Parent = screenGui

-- Отслеживание падений/бега (создание шума)
local humanoid = character:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function(_, newState)
	if newState == Enum.HumanoidStateType.Landed then
		-- При падении издается громкий шум, привлекающий монстра
		soundEvent:FireServer(hrp.Position)
		hintLabel.Text = "ВЫ ИЗДАЛИ ГРОМКИЙ ШУМ!"
		task.delay(2, function()
			hintLabel.Text = "[F] — Включить фонарик"
		end)
	end
end)