Need help on Switching the Camera System to First Person (Light Bulb free kit)

Hello Developers!
I’m here to ask for help on Editing the Code on the Free Kit named Light Bulb, It’s a Horror game kit I used.
I want to edit it. Because I think the camera system of it doesn’t fit the game.
ServerMainScript - A Script in ServerScriptService
1-794 line:


--[[  Variables  ]]--

local RepStorage				 =		 game:GetService("ReplicatedStorage")
local Lighting					 =		 game:GetService("Lighting")
local BadgeServ					 =		 game:GetService("BadgeService")
local RunServ					 =		 game:GetService("RunService")
local PhysicsService			 =		 game:GetService("PhysicsService")
local ScriptContext				 =		 game:GetService("ScriptContext")
local TweenService				 =		 game:GetService("TweenService")
local SoundServ					 =		 game:GetService("SoundService")
local DataStoreServ				 =		 game:GetService("DataStoreService")
local NotepadDatastore			 =		 DataStoreServ:GetDataStore("NotepadData")
local PlayerInALocker			 =		 false
local EleTouched				 =		 false
local Ch3MusicPlayed			 =		 false
local ReadyToBeCornered			 =		 false
local CornerLightFlicker		 =		 false
local Chapter3EndActivated		 =		 false
local HasGameStarted			 =		 false
local FlashlightTriggered		 =		 false
local EndGame					 =		 false
local PhoneSkipped				 =		 false
local CorneredAlready			 =		 false
local TrueEnding				 =		 false
local FinalKeyPickedUp			 =		 false
local FinalBlockTouched			 =		 false
local LockedSteam				 =		 false
local RotatingRacer				 =		 false
local MoveThing					 =		 true
local CodeDebounce				 =		 true
local KeyDebounce				 =		 true
local FallSceneActivated		 =		 false
local FallScenePlayerSafe		 =		 false
local GameEnded					 =		 false
local SteamOn					 =		 "First"
local sp						 =		 script.Parent
local EaI						 =		 game.Workspace:FindFirstChild("Entities/Interactions")
local EaIC						 =		 EaI:WaitForChild("CutsceneParts")
local FallScene					 =		 EaIC:WaitForChild("FallScene")

local info						 =		 TweenInfo.new(0.025,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local info2						 =		 TweenInfo.new(6.0,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local BaseVal					 =		 workspace.Building.MainMenu.Prim.MenuSubject.CFrame
local BaseCFrame				 =		 workspace.Cameras.CamModel.CamBas.CFrame
local Menu_CFVal				 =		 Instance.new("CFrameValue")
local ParentsOfInvisibles		 =		 {workspace.Building.First_Section.Hitboxes,
											workspace.Building.Second_section.Hitboxes,
											workspace.Building.Third_section.Hitboxes,
											workspace.Cameras,
											EaI.Particles,
											EaI.CameraChanges,
											EaI.TextBlocks,
											EaI.AudioPlays,
											EaI.AudioStops,
											EaI.AmbientNoises,
											EaI.BarBlocks,
											workspace.Building.Fourth_section.Hitboxes,
											workspace.Building.Fifth_section.Hitboxes,
											workspace.Building.Sixth_section.Hitboxes,
											workspace.Building.Seventh_section.Hitboxes}
local Doors						 =		 EaI.Doors:GetChildren()
local Keys						 =		 EaI.Keys:GetChildren()
local Lockers					 =		 EaI.Switches.Lockers:GetChildren()
local Texts						 =		 EaI.TextBlocks:GetChildren()
local Notes						 =		 EaI.Notes:GetChildren()
local AudioStarts				 =		 EaI.AudioPlays:GetChildren()
local BarBlocks					 =		 EaI.BarBlocks:GetChildren()
local AudioStops				 =		 EaI.AudioStops:GetChildren()
local AmbientBlocks				 =		 EaI.AmbientNoises:GetChildren()
local PhoneBlocks				 =		 EaI.Phones:GetChildren()
local HideBlocks				 =		 EaI.HideSeek:GetChildren()
local PushingBoxes				 =		 EaI.Boxes:GetChildren()
local MetalDoors				 =		 EaI.MetalDoors:GetChildren()
local InsanityLevel				 =		 0 
local Cutscene2Trigger			 =		 1
local ElevatorNumber			 =		 17
local TheSpecialValX			 =		 0
local SpecialValY				 =		 0
local FallSceneTimeCount		 =		 13
local ColonistCount				 =		 12014
local LeversFlicked				 =		 0
local mks
local Data
--[[  Functions  ]]--

local function ExecuteFormula1(Val1)
	local Val2 = Val1*0.01
	local PositionToMove = BaseVal*CFrame.new(Val2,0,0)
	return PositionToMove
end

function round(num,nearest)
	num = num/nearest
	num = math.floor(num+0.5)
	num = num*nearest
	return num, num/nearest
end

local function tweenModel(model, CF, InfoToTake)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	local tween
	if InfoToTake == nil or InfoToTake == 1 then
		tween = TweenService:Create(CFrameValue, info, {Value = CF})
	elseif InfoToTake == 2 then
		tween = TweenService:Create(CFrameValue, info2, {Value = CF})
	end
	tween:Play()
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

local function CameraTouchEvents(Object)
	Object.Touched:Connect(function(TouchedPart)
		local PlayerTouched = game.Players:GetPlayerFromCharacter(TouchedPart.Parent)
		if PlayerTouched ~= nil then
			RepStorage.ChangeCamera:FireClient(PlayerTouched,
				Object.CamZoomField.Value,
				Object.CameraAngle.Value,
				Object.CameraSpeed2.Value,
				Object.DistanceFromChar.Value,
				Object.OnArena.Value,
				Object.TopDown.Value,
				Object.Zoom.Value)
			if Object.BlockToChangeTo.Value ~= nil then
				game.Workspace.Cameras.CameraArena.CFrame = Object.BlockToChangeTo.Value.CFrame
			end
		end
	end)
end



local function enableit(myslot,num)
	myslot:FindFirstChild("Thing"..num).BrickColor = BrickColor.new("Really red")
	myslot:FindFirstChild("Thing"..num).Material = Enum.Material.Neon
end


local function ElevatorAction(num,slot)
	local myslot = EaIC.Ele2:FindFirstChild("Slot" .. slot)
	
	local num = tonumber(num)
	if num == 1 then
		enableit(myslot,1)
		enableit(myslot,2)
	elseif num == 2 then
		enableit(myslot,2)
		enableit(myslot,3)
		enableit(myslot,5)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 3 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,3)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 4 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,4)
		enableit(myslot,7)
	elseif num == 5 then
		enableit(myslot,1)
		enableit(myslot,3)
		enableit(myslot,4)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 6 then
		enableit(myslot,1)
		enableit(myslot,3)
		enableit(myslot,4)
		enableit(myslot,5)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 7 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,3)
	elseif num == 8 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,3)
		enableit(myslot,4)
		enableit(myslot,5)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 9 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,3)
		enableit(myslot,4)
		enableit(myslot,6)
		enableit(myslot,7)
	elseif num == 0 then
		enableit(myslot,1)
		enableit(myslot,2)
		enableit(myslot,3)
		enableit(myslot,4)
		enableit(myslot,5)
		enableit(myslot,6)
	end
end


local function FlashbackScene(plr)
	wait(1)
	plr.Character.HumanoidRootPart.CFrame = EaIC.FlashbackScene.PlayerSpawn.CFrame
	RepStorage.Blackout:FireClient(plr,false,1)
	wait(3)
	local aud = script.Flashlight:Clone()
	aud.Parent = plr.Character.HumanoidRootPart
	aud:Play()
	game.Debris:AddItem(aud,aud.TimeLength)
	local Light = Instance.new("PointLight",plr.Character.HumanoidRootPart)
	Light.Brightness = 1.25
	Light.Range = 15
	Light.Color = Color3.fromRGB(240,240,230)
	Light.Name = "FlashbackLight"
	RepStorage.Splash:FireClient(plr, "Your text here")
	RepStorage.Fusebox.OnServerEvent:Wait()
	local aud = script.fuse:Clone()
	aud.Parent = EaIC.FlashbackScene.TurnOnLight.TurnOnLight
	aud:Play()
	game.Debris:AddItem(aud,aud.TimeLength)
	RepStorage.Splash:FireClient(plr, "That should do it, back to bed I go.")
	EaIC.FlashbackScene.TvTrigger.Touched:Wait()
	EaIC.FlashbackScene.TV.Screen.Sound:Play()
	TweenService:Create(Light,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{Brightness = 0}):Play()
	spawn(function()
		for i = 38, 26, -1 do
			EaIC.FlashbackScene.TV.Screen.SurfaceGui.BlueBack.Timer.Text = "00:29:"..tostring(i)
			wait(1)
		end
	end)
	EaIC.FlashbackScene.TV.Screen.SurfaceGui.Enabled = true
	for _,v in pairs(EaIC.FlashbackScene.TV.LightBlocks:GetChildren()) do
		v.Light.Enabled = true
	end
	wait(0.2)
	plr.Character.Humanoid.WalkSpeed = 0
	wait(0.35)
	Light:Destroy()
	EaIC.FlashbackScene.TvBarrier1.CanCollide = true
	EaIC.FlashbackScene.TvBarrier2.CanCollide = true
	local gyroclone = Instance.new("BodyGyro")
	gyroclone.Parent = plr.Character.HumanoidRootPart
	gyroclone.P = 6000
	gyroclone.MaxTorque = Vector3.new(40000000,50000,40000000)
	gyroclone.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position,EaIC.FlashbackScene.TV.Screen.Position)
	wait(3.55)
	EaIC.FlashbackScene.SirenPart.Sound:Play()
	wait(8.5)
	EaIC.FlashbackScene.TV.Screen.Sound:Stop()
	EaIC.FlashbackScene.SirenPart.Sound:Stop()
	gyroclone:Destroy()
end

local function FlashlightEvent(plr,val)
	if val == true and FlashlightTriggered == false then
		FlashlightTriggered = true
		RepStorage.Blackout:FireClient(plr,true,0)
		EaIC.Blackout2.Transparency = 0
		EaIC.Blackout1.Transparency = 1
		EaIC.Wallpart1.Transparency = 0
		EaIC.Wallpart2.Transparency = 0
		EaIC.Wallpart2.Texture.Transparency = 0

		FlashbackScene(plr)
		RepStorage.Blackout:FireClient(plr,true,0)
		wait(0.5)
		script.FlashlightDoor.Value.EventLock.Value = true
		script.FlashlightDoor.Value.Inner.Union.Anchored = true
		script.FlashlightDoor2.Value.EventLock.Value = false
		script.FlashlightDoor2.Value.Unopenable.Value = false
		script.FlashlightDoor2.Value.Inner.Union.Anchored = false
		plr.Character.Humanoid.WalkSpeed = 0
		plr.Character.HumanoidRootPart.CFrame = EaIC.FlashTele.CFrame
		wait(1.2)
		plr.Character.Humanoid.WalkSpeed = 14
		wait(1)
		RepStorage.Blackout:FireClient(plr,false,1,1)
	elseif val == false then--reset if plr ded
		EaIC.Blackout2.Transparency = 1
		EaIC.Blackout1.Transparency = 0
		script.FlashlightDoor.Value.EventLock.Value = false
		script.FlashlightDoor.Value.Inner.Union.Anchored = false
		script.FlashlightDoor2.Value.EventLock.Value = true
		script.FlashlightDoor2.Value.Unopenable.Value = true
		script.FlashlightDoor2.Value.Inner.Union.Anchored = true
		--EaIC.Wallpart1.Transparency = 1
		FlashlightTriggered = false
		--EaIC.Wallpart2.Transparency = 1
		--EaIC.Wallpart2.Texture.Transparency = 1
	end
end

local function RunFinalCheck()
	if CodeDebounce == false and KeyDebounce == false then
		local mylastlights = script.LastLights.Value:GetChildren()
		for i = 1, #mylastlights do
			mylastlights[i].SpotLight.Enabled = false
		end
		EaIC.SoundBrick.ShutDown:Play()
		wait(4)
		local mysirens = EaI.Sirens:GetChildren()
		for i = 1, #mysirens do
			local rotatethething = coroutine.wrap(function(MineToLoop)
				while wait(0.05) do
					MineToLoop.RotatePart.CFrame = MineToLoop.RotatePart.CFrame * CFrame.Angles(0,0,math.rad(4))
				end
			end)
			mysirens[i].Shell.Sound:Play()
			mysirens[i].Shell.Material = Enum.Material.Neon
			mysirens[i].RotatePart.SpotLight.Enabled = true
			mysirens[i].RotatePart.SpotLight2.Enabled = true
			mysirens[i].RotatePart.Beam.Enabled = true
			mysirens[i].RotatePart.Beam2.Enabled = true
			rotatethething(mysirens[i])
		end
		
		wait(3)
		local decreasecolonistcount = coroutine.wrap(function()
			script.ColonistCount.Changed:Connect(function(val)
				EaIC.Monitor3.Part.SurfaceGui.TX3.Text = "Colonists : " .. tostring(round(val,1))
			end)
			local mytween = TweenService:Create(script.ColonistCount,TweenInfo.new(5.4,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Value = 0})
			mytween:Play()
		end)
		local endthelives = coroutine.wrap(function()
			local mypods = EaI.Pods:GetChildren()
			for i = 1, #mypods do
				mypods[i].Light1.BrickColor = BrickColor.new("Really red")
				mypods[i].Light1.Material = Enum.Material.Neon
				mypods[i].Light1.PointLight.Color = Color3.fromRGB(255,0,0)
				mypods[i].Light2.BrickColor = BrickColor.new("Really red")
				mypods[i].Light2.Flatline:Play()
				mypods[i].Light2.Material = Enum.Material.Neon
				mypods[i].Light2.PointLight.Color = Color3.fromRGB(255,0,0)
				wait(math.random(7,14)/10)
			end
		end)
		EaIC.Monitor3.Part.SurfaceGui.TX2.Text = "Sanctuary : Inactive"
		wait(4)
		RotatingRacer = false
		EaIC.racer6743:Destroy()
		EaIC.HoloLight.ParticleEmitter.Enabled = false
		EaIC.HoloLight.PointLight.Enabled = false
		EaIC.HoloLight.Material = Enum.Material.SmoothPlastic
		EaIC.HoloLight.BrickColor = BrickColor.Black()
		EaIC.Monitor3.Part.SurfaceGui.TX7.Text = "Life Support : Inactive"
		decreasecolonistcount()
		endthelives()
		wait(2)
		EaIC.Monitor3.Part.SurfaceGui.TX5.Text = "Cooling : Inactive"
		EaIC.Monitor3.Part.SurfaceGui.TX4.Text = "Mode : Abyss"
		local mylights = EaIC.LightsToToggle:GetChildren()
		for i = 1, #mylights do
			wait(math.random(1,2)/150)
			mylights[i].PointLight.Color = Color3.fromRGB(255,0,0)
			mylights[i].BrickColor = BrickColor.Red()
			
		end
		EaIC.ServerBlock.ServerSound:Stop()
		wait(3)
		EaIC.Monitor3.Part.SurfaceGui.TX6.Text = "Fluothane : Inactive"
		TrueEnding = true
	end
end

local function Chap3Thing(part)
	wait(2)
	part.Parent.HumanoidRootPart.CFrame = CFrame.new(EaIC.Ele2.TpBlock.Position)
	part.Parent.Humanoid.AutoRotate = true
	local dothingforaudio = coroutine.wrap(function()
		EaIC.Ele2.Sound.ElevatorIdle.Volume = 0
		EaIC.Ele2.Sound.ElevatorIdle:Play()
		for i = 0, 1, 0.1 do
			EaIC.Ele2.Sound.ElevatorIdle.Volume = i
			wait(0.075)
		end
	end)
	local dothingforaudio2 = coroutine.wrap(function()
		EaIC.Ele2.SoundBlock.ElevatorMusic.Volume = 0
		EaIC.Ele2.SoundBlock.ElevatorMusic:Play()
		for i = 0, 0.5, 0.025 do
			EaIC.Ele2.SoundBlock.ElevatorMusic.Volume = i
			wait(1)
		end
	end)
	dothingforaudio()
	dothingforaudio2()
	repeat
		wait(1.5)
		ElevatorNumber = ElevatorNumber - 1
		local numbutstring = tostring(ElevatorNumber)
		local var = numbutstring:len()
		local c = EaIC.Ele2.Slot1:GetChildren()
		for i = 1, #c do
			c[i].BrickColor = BrickColor.Black()
			c[i].Material = Enum.Material.Metal
		end
		local c = EaIC.Ele2.Slot2:GetChildren()
		for i = 1, #c do
			c[i].BrickColor = BrickColor.Black()
			c[i].Material = Enum.Material.Metal
		end
		local c = EaIC.Ele2.Slot3:GetChildren()
		for i = 1, #c do
			c[i].BrickColor = BrickColor.Black()
			c[i].Material = Enum.Material.Metal
		end
		for i = 1, numbutstring:len() do
			ElevatorAction(string.sub(numbutstring,i,i),var)
			var = var - 1
		end
	until ElevatorNumber == 1
	EaIC.Ele2.SoundBlock.ElevatorMusic.Volume = 0
	EaIC.Ele2.SoundBlock.ElevatorMusic:Stop()
	EaIC.Ele2.Sound.ElevatorIdle.Volume = 0
	EaIC.Ele2.Sound.ElevatorIdle:Stop()
	EaIC.Ele2.Sound.ElevatorBell:Play()
	part.Parent.Humanoid.WalkSpeed = 14
	local ele = EaIC.Ele2
	ele.DownBoy1.Material = Enum.Material.Metal
	ele.DownBoy1.BrickColor = BrickColor.Black()
	ele.DownBoy2.Material = Enum.Material.Metal
	ele.DownBoy2.BrickColor = BrickColor.Black()
	local thing = TweenService:Create(ele.Door1,TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In),{Position = ele.Door1.Position + Vector3.new(2.9,0,0)})
	thing:Play()
	local thing2 = TweenService:Create(ele.Door2,TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In),{Position = ele.Door2.Position - Vector3.new(2.9,0,0)})
	thing2:Play()
	wait(1.8)
end

local function Chap4Thing(part)
	wait(2)
	part.Parent:WaitForChild("HumanoidRootPart").CFrame = EaIC.Ch4TelePart.CFrame
end

local function Chap5Thing(part)
	wait(2)
	part.Parent:WaitForChild("HumanoidRootPart").CFrame = EaIC.Ch5Tp.CFrame
end

local function DoPanelEvent(Plr,Obj)
	LeversFlicked = LeversFlicked + 1
	if LeversFlicked == 1 then
		EaIC.NoSign.Decal.Transparency = 0
		Plr.Character.HumanoidRootPart.CFrame = EaIC.EndTeleportPart.CFrame
		EaIC.StopItSign.Decal.Transparency = 0
		workspace.Sounds.GlitchNoise1.PlaybackSpeed = 1
		workspace.Sounds.GlitchNoise2.PlaybackSpeed = 1
		workspace.Sounds.GlitchNoise1:Play()
		workspace.Sounds.GlitchNoise2:Play()
	elseif LeversFlicked == 2 then
		Plr.Character.HumanoidRootPart.CFrame = EaIC.EndTeleportPart.CFrame
		local myobjects = EaIC.BlocksToShow:GetChildren()
		workspace.Sounds.GlitchNoise1.PlaybackSpeed = 1.6
		workspace.Sounds.GlitchNoise2.PlaybackSpeed = 1.6
		for i = 1, #myobjects do
			myobjects[i].CanCollide = true
			if myobjects[i].Name ~= "Hitbox" then
				myobjects[i].Transparency = 0
			end
		end
	elseif LeversFlicked == 3 then
		workspace.Sounds.GlitchNoise1.PlaybackSpeed = 5
		workspace.Sounds.GlitchNoise2.PlaybackSpeed = 5
		wait(0.45)
		EndGame = true
		RepStorage.ActivateEnd:FireClient(Plr)
		RotatingRacer = true
		workspace.Sounds.GlitchNoise1:Stop()
		workspace.Sounds.GlitchNoise2:Stop()
		Plr.Character.Humanoid.WalkSpeed = 10
		SoundServ.AmbientReverb = Enum.ReverbType.ParkingLot
		game.Lighting.GoodEndBlur.Enabled = true
		game.Workspace.Sounds.Ambience:Play()
		Plr.Character.HumanoidRootPart.CFrame = EaIC.LastTeleport.CFrame	
		Lighting:WaitForChild("Sky"):Destroy()
		local Newsky = game.ServerStorage.DevArchives.Celestial:Clone()
		Newsky.Parent = Lighting	
	end
end

local function HandleDeath(Plr,Cause)
	if Cause == "Void" then
		BadgeServ:AwardBadge(Plr.UserId,2124478258)
	elseif Cause == "Monster" then
		local MyAudio = workspace:FindFirstChild("ScaryAmbiance")
		if MyAudio then
			for i = MyAudio.Volume, 0, -0.1 do
				wait(0.025)
				MyAudio.Volume = i
			end
			MyAudio:Destroy()
		end
	end
	Plr.Character.Humanoid.WalkSpeed = 0
	Plr.Character.Humanoid.JumpPower = 0
	RepStorage.Death:FireClient(Plr,Cause)
end

--[[local function DoGlitchParticle(active,OneToEnable)
	local function disableall()
		local myones = EaI.HideSeek:GetChildren()
		for i = 1, #myones do
			local thesecondones = myones[i]:GetChildren()
			for sk = 1, #thesecondones do
				if string.match(thesecondones[sk].Name,"Room.+") ~= nil then
					if thesecondones[sk].GlitchParticles.Value ~= nil then
						local particleparts = thesecondones[sk].GlitchParticles.Value:GetChildren()
						for md = 1, #particleparts do
							particleparts[md]:WaitForChild("ParticleEmitter").Enabled = false
						end
					end
				end
			end
		end
	end
	if active == false then
		disableall()
	elseif active == true then
		disableall()
		if OneToEnable.GlitchParticles.Value ~= nil then
			local particleparts = OneToEnable.GlitchParticles.Value:GetChildren()
			for md = 1, #particleparts do
				particleparts[md].ParticleEmitter.Enabled = true
			end
		end
	end
end--]]

local function FlickerLights(Active,Lights2Flick)
	local function EnableAll()
		local myones = EaI.HideSeek:GetChildren()
		for i = 1, #myones do
			local thesecondones = myones[i]:GetChildren()
			for sk = 1, #thesecondones do
				if string.match(thesecondones[sk].Name,"Room.+") ~= nil then
					if thesecondones[sk].Lights.Value ~= nil then
						local lightparts = thesecondones[sk].Lights.Value:GetChildren()
						if thesecondones[sk].Lights.Value:FindFirstChild("Flickering") then
							thesecondones[sk].Lights.Value:FindFirstChild("Flickering"):Destroy()
							for md = 1, #lightparts do
								if lightparts[md]:IsA("Part") and lightparts[md].LightObj.Brightness ~= 0 then
									lightparts[md]:WaitForChild("LightObj").Brightness = 1
									print("Fixed!")
								end
							end
						end
					end
				end
			end
		end
	end
	EnableAll()
	if Lights2Flick ~= nil then
		local SpookyLights = Lights2Flick:WaitForChild("Lights").Value:GetChildren()
		local FlickerLoop = coroutine.wrap(function()
			wait()
			if not SpookyLights[1].Parent:FindFirstChild("Flickering") then
				local FlickOBJ = Instance.new("SunRaysEffect")
				FlickOBJ.Parent = SpookyLights[1].Parent
				FlickOBJ.Name = "Flickering"
				while SpookyLights[1].Parent:FindFirstChild("Flickering") and SpookyLights[1].LightObj.Brightness ~= 0 do
					for i = 1, #SpookyLights do
						if SpookyLights[i]:IsA("Part") then
							SpookyLights[i].LightObj.Brightness = 0.5
						end
					end
					wait(0.11)
					for i = 1, #SpookyLights do
						if SpookyLights[i]:IsA("Part") then
							SpookyLights[i].LightObj.Brightness = 1
						end
					end
					wait(math.random(1,20)/75)
					for i = 1, #SpookyLights do
						if SpookyLights[i]:IsA("Part") then
							SpookyLights[i].LightObj.Brightness = 0.65
						end
					end
					wait(0.085)
				end
				print("I stopped")
				local Number2Do = 1
				if not SpookyLights[1]:IsA("Part") then
					Number2Do = 2
				end
				if SpookyLights[Number2Do].LightObj.Brightness ~= 0 and SpookyLights[Number2Do].Parent:FindFirstChild("Flickering") then
					for i = 1, #SpookyLights do
						if SpookyLights[i]:IsA("Part") then
							SpookyLights[i].LightObj.Brightness = 1
							SpookyLights[Number2Do].Parent:FindFirstChild("Flickering"):Destroy()
						end
					end
				end
			end
		end)
		FlickerLoop()
	end
	--[[if Active == false then
		StopFlickering = true
		wait()
		StopFlickering = false
	end--]]
end

local function manageHide(HideAndSeek)
	local DefaultMon = HideAndSeek.MonsterNum.Value
	local DefaultPlay = HideAndSeek.PlayerNum.Value
	local MonVal = HideAndSeek.MonsterNum
	local PreviousVal = MonVal.Value
	local PlayVal = HideAndSeek.PlayerNum
	local PlayerInMaze = false
	local CurrentPlayer = nil
	local FirstRooms = HideAndSeek:GetChildren()
	local Rooms = {}
	for i = 1, #FirstRooms do
		if FirstRooms[i]:IsA("Part") then
			table.insert(Rooms,1,FirstRooms[i])
		end
	end
	local function OnAction()
		local RoomToCheck = HideAndSeek:FindFirstChild("Room" .. MonVal.Value)
		local NextRoom = nil
		local RoomToCheckChil = RoomToCheck:GetChildren()
		for i = 1, #RoomToCheckChil do
			if RoomToCheckChil[i].Name == "Default" then
				NextRoom = RoomToCheckChil[i].Value
			end
		end
		local NextRoom = HideAndSeek:FindFirstChild("Room"..NextRoom)
		NextRoom.GlitchSound.TimePosition = RoomToCheck.GlitchSound.TimePosition
		NextRoom.GlitchSound:Resume()
		RoomToCheck.GlitchSound:Stop()
		local Lights1 = RoomToCheck.Lights.Value:GetChildren()
		local Lights2 = NextRoom.Lights.Value:GetChildren()
		local dolight1 = coroutine.wrap(function()
			for mk = 1, #Lights1 do
				if Lights1[mk]:IsA("Part") then
					Lights1[mk].LightObj.Enabled = true
					local insidelightloop = coroutine.wrap(function(mylight)
						for sf = 0, 1, 0.1 do
							if mylight:IsA("Part") and not mylight:IsA("SunRaysEffect") then
								mylight.LightObj.Brightness = sf
								wait(.1)
							end
						end
					end)
					insidelightloop(Lights1[mk])
				end
			end
		end)
		local dolight2 = coroutine.wrap(function()
			for mk = 1, #Lights2 do
				if Lights2[mk]:IsA("Part") then
					local insidelightloop = coroutine.wrap(function(mylight)
						for sf = 1, 0, -0.1 do
							if mylight:IsA("Part") then
								mylight.LightObj.Brightness = sf
								wait(.1)
							end
						end
						if mylight:IsA("Part") and not mylight:IsA("SunRaysEffect") then
							mylight.LightObj.Enabled = false
						end
					end)
					insidelightloop(Lights2[mk])
				end
			end
		end)
		dolight1()
		dolight2()
		PreviousVal = MonVal.Value
		MonVal.Value = NextRoom.MyNum.Value
		FlickerLights(true, HideAndSeek:FindFirstChild("Room".. HideAndSeek:FindFirstChild("Room" .. MonVal.Value).Default.Value))
		if PlayerInALocker == false and MonVal.Value == PlayVal.Value or PlayVal.Value == PreviousVal and PlayerInALocker == false then
			HandleDeath(CurrentPlayer, "Monster")
		end
	end
	local TotalNum = #Rooms
	for i = 1, #Rooms do
		Rooms[i].Touched:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) and PlayVal.Value ~= Rooms[i].MyNum.Value and PlayerInMaze == true then
				PlayVal.Value = Rooms[i].MyNum.Value
				OnAction()
			end
		end)
	end
	script.InLocker.Event:Connect(function()
		if PlayerInMaze == true and PlayerInALocker == true then
			wait(0.1)
			OnAction()
			repeat
				wait(2)
				if PlayerInALocker == true then
					OnAction()
				end
			until PlayerInALocker == false
		elseif PlayerInMaze == true and PlayerInALocker == false then
			if MonVal.Value == PlayVal.Value then
				OnAction()
			end
		end
		if PlayerInALocker == false then
			
		end
	end)
	script.ResetHideSeeks.Event:Connect(function()
		PlayerInMaze = false
		FlickerLights(false)
		MonVal.Value = DefaultMon
		PlayVal.Value = DefaultPlay
		for i = 1, #Rooms do
			local lights = Rooms[i].Lights.Value:GetChildren()
			if Rooms[i].MyNum.Value ~= DefaultMon then
				for md = 1, #lights do
					if lights[md]:IsA("Part") then
						lights[md].LightObj.Enabled = true
						lights[md].LightObj.Brightness = 1
					end
				end
			elseif Rooms[i].MyNum.Value == DefaultMon then
				for md = 1, #lights do
					if lights[md]:IsA("Part") then
						lights[md].LightObj.Enabled = false
						lights[md].LightObj.Brightness = 0
					end
				end
			end
		end
	end)
	local Enables = HideAndSeek.Enables:GetChildren()
	local ButtonDoors = HideAndSeek.ButtonDoors:GetChildren()
	local Disables = HideAndSeek.Disables:GetChildren()
	for i = 1, #Enables do
		Enables[i].Touched:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) then
				PlayerInMaze = true
				FlickerLights(true, HideAndSeek:FindFirstChild("Room".. HideAndSeek:FindFirstChild("Room" .. MonVal.Value).Default.Value))
				CurrentPlayer = game.Players:GetPlayerFromCharacter(part.Parent) 
			end
		end)
	end
	for i = 1, #Disables do
		Disables[i].Touched:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) then
				PlayerInMaze = false
				CurrentPlayer = nil
				FlickerLights(false)
			end
		end)
	end
	for i = 1, #ButtonDoors do
		local MyDoor = ButtonDoors[i]
		MyDoor.Open.Changed:Connect(function(val)
			if val == true and PlayerInMaze == true then
				local example = MyDoor.DoorPart:Clone()
				example.Parent = workspace
				example.CanCollide = false
				example.Anchored = false
				OnAction()
				MyDoor.DoorPart.Transparency = 1
				MyDoor.DoorPart.CanCollide = false
				MyDoor.DoorPart.beep:Play()
				MyDoor.Light.BrickColor = BrickColor.new("Lime green")
			elseif val == false and PlayerInMaze == true then
				MyDoor.DoorPart.Transparency = 0
				MyDoor.DoorPart.CanCollide = true
				MyDoor.Light.BrickColor = BrickColor.new("Really red")
			end
		end)
		MyDoor.Button.Touched:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) and MyDoor.Open.Value == false then
				MyDoor.Open.Value = true
			end
		end)
		script.ResetHideSeeks.Event:Connect(function()
			MyDoor.Open.Value = false
			wait(3)
			MyDoor.Open.Value = false
		end)
	end
end

795-1638:


local function TheSecondTrap(plr)
	local isitdone = false
	local domeadebounce = false
	local isheckhappening = false
	local killdebounc = false
	local MyAudio = workspace:FindFirstChild("ScaryAmbiance")
	if MyAudio then
		for i = MyAudio.Volume, 0, -0.1 do
			wait(0.025)
			MyAudio.Volume = i
		end
		MyAudio:Destroy()
	end
	script.TrappedRoom2Door.Value.EventLock.Value = true
	script.TrappedRoom2Door.Value.Inner.Union.Anchored = true
	local dolightuntil = coroutine.wrap(function()
		local halllights = script.TrappedRoom2HallLight.Value:GetChildren()
		for i = 1, #halllights do
			halllights[i].LightObj.Brightness = 0
		end
		local mydodo = 0
		local mylights = script.TrappedRoom2Light.Value:GetChildren()
		repeat
			for i = 1, 0, -0.1 do
				for sk = 1, #mylights do
					mylights[sk].LightObj.Brightness = i
				end
				wait(0.015)
			end
			for i = 0, 1, 0.1 do
				for sk = 1, #mylights do
					mylights[sk].LightObj.Brightness = i
				end
				wait(0.015)
			end
			if mydodo ~= 50 then
				mydodo = mydodo+1
			else
				local halllights = script.TrappedRoom2HallLight.Value:GetChildren()
				for i = 1, #halllights do
					halllights[i].LightObj.Brightness = 1
				end
				if workspace:FindFirstChild("Ost2") then
					game.Workspace.Ost2:Stop()
					game.Workspace.Ost2:Destroy()
				end
				HandleDeath(plr,"Monster")
				killdebounc = true
				break
			end
		until isitdone == true
		for sk = 1, #mylights do
			mylights[sk].LightObj.Brightness = 0
		end
		wait(15)
		for sk = 1, #mylights do
			mylights[sk].LightObj.Brightness = 0.4
		end
		wait(0.1)
		for sk = 1, #mylights do
			mylights[sk].LightObj.Brightness = 0
		end
		wait(0.75)
		for i = 0, 1, 0.05 do
			for sk = 1, #mylights do
				mylights[sk].LightObj.Brightness = i
			end
			wait(0.01)
		end
	end)
	dolightuntil()
	EaIC.MovingBookShelf.Trigger.Touched:Connect(function(part)
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr and domeadebounce == false and killdebounc == false then
			domeadebounce = true
			isitdone = true
			isheckhappening = true
			if workspace:FindFirstChild("Ost2") then
				game.Workspace.Ost2:Stop()
				game.Workspace.Ost2:Destroy()
			end
			EaIC.MovingBookShelf.DeathToThee.Touched:Connect(function(part)
				local plr = game.Players:GetPlayerFromCharacter(part.Parent)
				if plr and isheckhappening == true and killdebounc == false then
					killdebounc = true
					if workspace:FindFirstChild("Ost2") then
						game.Workspace.Ost2:Stop()
						game.Workspace.Ost2:Destroy()
					end
					local halllights = script.TrappedRoom2HallLight.Value:GetChildren()
					for i = 1, #halllights do
						halllights[i].LightObj.Brightness = 1
					end
					HandleDeath(plr,"Monster")
				end
			end)
			wait(8.25)
			if killdebounc == false then
				TweenService:Create(EaIC.MovingBookShelf.BuildingPart.PrimaryPart,TweenInfo.new(2.2,Enum.EasingStyle.Sine),{CFrame = EaIC.MovingBookShelf.BuildingPart.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(-8))}):Play()
				EaIC.MovingBookShelf.BuildingPart.PrimaryPart.Scrape:Play()
			end
			wait(8)
			EaIC.MovingBookShelf.IKnowText1.Decal.Transparency = 0
			EaIC.MovingBookShelf.IKnowText2.Decal.Transparency = 0
			local halllights = script.TrappedRoom2HallLight.Value:GetChildren()
				for i = 1, #halllights do
					halllights[i].LightObj.Brightness = 1
				end
			script.TrappedRoom2Door.Value.Inner.Union.Anchored = false
			local MyAudio = script.ScaryAmbiance:Clone()
			MyAudio.Parent = workspace
			MyAudio.Volume = 0
			MyAudio:Play()
			spawn(function()
				wait(4)
				for i = 0, 0.5, 0.05 do
					wait(0.05)
					MyAudio.Volume = i
				end
			end)
			isheckhappening = false
		end
	end)
end


local function PhoneEvents(Obj)
	local ringing = false
	local picked_up = false
	local function awaitinput()
		if ringing == true and picked_up == false then
			RepStorage.Phone.OnServerEvent:Connect(function(plr)
				if ringing == true and picked_up == false then
					ringing = false
					picked_up = true
					Obj.PhoneModel.WeldingPart.PhoneRing:Stop()
					plr.Character.Humanoid.WalkSpeed = 0
					plr.Character.Humanoid.JumpPower = 0
					Obj.Base.CFrame = Obj.Base.CFrame *CFrame.new(0,50,0)
					plr.Character.HumanoidRootPart.CFrame = Obj.PlayerWeldPart.CFrame
					wait(0.1)
					plr.Character.HumanoidRootPart.Anchored = true
					local childrenthings = Obj.PhoneModel.Cords:GetChildren()
					for i = 1, #childrenthings do
						local m = childrenthings[i]:GetChildren()
						for sk = 1, #m do
							if m[sk]:IsA("RopeConstraint") or m[sk]:IsA("SpringConstraint") then
								m[sk].Visible = false
							end
						end
					end
					local anim1 = plr.Character.Humanoid:LoadAnimation(script.Pickup)
					local anim2 = plr.Character.Humanoid:LoadAnimation(script.Hold)
					local anim3 = plr.Character.Humanoid:LoadAnimation(script.PutDown)
					anim1:Play()
					wait(0.3)
					local WeldingPart = Obj.PhoneModel.WeldingPart:Clone()
					WeldingPart.Parent = Obj.PhoneModel
					WeldingPart.Name = "ClonedBrick"
					Obj.PhoneModel.WeldingPart.Transparency = 1
					Obj.PhoneModel.WeldingPart.Part.Transparency = 1
					local m = Instance.new("Motor6D")
					m.Parent = WeldingPart
					WeldingPart.RopeConstraint.Visible = true
					WeldingPart.RopeConstraint.Enabled = true
					WeldingPart.Anchored = false
					WeldingPart.CFrame = plr.Character.RightHand.CFrame*CFrame.Angles(0,0,-90)*CFrame.new(0.15,0,0)
					m.C1 = WeldingPart.CFrame:inverse()
					m.Part1 = WeldingPart
					m.C0 = plr.Character.RightHand.CFrame:inverse()
					m.Part0 = plr.Character.RightHand
					Obj.PhoneModel.WeldingPart.PhonePickUp:Play()
					local specialcode = Obj.SpecialInstructions.Value
					if specialcode == 1 then
						local specialcoro = coroutine.wrap(function()
							wait(WeldingPart.PhoneCall.TimeLength -0.05)
							local audio = script.Ost2:Clone()
							audio.Parent = workspace
							audio:Play()
							for i = 0, 2.5, 0.1 do
								wait(0.02)
								audio.Volume = i
							end
							TheSecondTrap(plr)
						end)
						specialcoro()
					elseif specialcode == 2 then
						local blockhit = false
						local LightLoop = coroutine.wrap(function()
							wait(27)
							repeat
								local mylights =  script.LastPhoneTrap.Value:GetChildren()
								wait(math.random(0,4)/10)
								for sk = 1, 0.25, -.05 do
									for i = 1, #mylights do
										if mylights[i]:IsA("Part") then
											mylights[i].LightObj.Brightness = sk
										end
									end
									wait(0.0025)
								end
								wait(math.random(0,4)/10)
								for sk = 0.25, 1, .05 do
									for i = 1, #mylights do
										if mylights[i]:IsA("Part") then
											mylights[i].LightObj.Brightness = sk
										end
									end
									wait(0.0025)
								end
								wait(math.random(0,4)/10)
							until blockhit == true
							local mylights =  script.LastPhoneTrap.Value:GetChildren()
							for sk = 1, 0.25, -.05 do
								for i = 1, #mylights do
									if mylights[i]:IsA("Part") then
										mylights[i].LightObj.Brightness = sk
									end
								end
								wait(0.0025)
							end
						end)
						LightLoop()
						EaIC.PhoneBlock.CanCollide = true
						EaIC.ActivateLightsOut.Touched:Connect(function(part)
							if game.Players:GetPlayerFromCharacter(part.Parent) and not blockhit then
								blockhit = true
								EaIC.LeverRoomBlock.CanCollide = true
							end
						end)
					end
					local mycapt = Obj.MyCallNum.Value
					RepStorage.PhoneCaption:FireClient(plr,mycapt,Obj)
					wait(0.6)
					anim2:Play()
					WeldingPart.PhoneCall:Play()
					if Obj.AbleToSkip.Value == false then
						wait(WeldingPart.PhoneCall.TimeLength)
					else
						for i = 1, 20 do
							if PhoneSkipped == false and Obj.AbleToSkip.Value == true then
								wait(WeldingPart.PhoneCall.TimeLength/20)
							end
						end
					end
					if mycapt == 5 then
						script.FinalDoor.Value.Open:Fire()
					end
					WeldingPart.PhoneCall:Stop()
					WeldingPart.PhoneDead:Play()
					wait(2.05)
					WeldingPart.PhoneDead:Stop()
					anim3:Play()
					wait(0.05)
					Obj.PhoneModel.WeldingPart.PhoneHangUp:Play()
					Obj.PhoneModel.WeldingPart.ClickSound:Play()
					WeldingPart:Destroy()
					wait(0.35)
					plr.Character.Humanoid.JumpPower = 35
					plr.Character.Humanoid.WalkSpeed = 14
					local childrenthings = Obj.PhoneModel.Cords:GetChildren()
					Obj.PhoneModel.WeldingPart.Transparency = 0
					plr.Character.HumanoidRootPart.Anchored = false
					Obj.PhoneModel.WeldingPart.Part.Transparency = 0
					for i = 1, #childrenthings do
						local m = childrenthings[i]:GetChildren()
						for sk = 1, #m do
							if m[sk]:IsA("RopeConstraint") or m[sk]:IsA("SpringConstraint") then
								m[sk].Visible = true
							end
						end
					end
					local stopwalls = Obj.Stoppers:GetChildren()
					for lol = 1, #stopwalls do
						stopwalls[lol].CanCollide = false
					end
					PhoneSkipped = false
					anim2:Stop()
				end
			end)
		end
	end
	local stopwalls = Obj.Stoppers:GetChildren()
	for lol = 1, #stopwalls do
		stopwalls[lol].Touched:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) and stopwalls[lol].CanCollide == true then
				RepStorage.Splash:FireClient(game.Players:GetPlayerFromCharacter(part.Parent), "I should answer that call before moving on...")
			end
		end)
	end
	script.ResetPhones.Event:Connect(function()
		if picked_up == true then
			picked_up = false
			Obj.Base.CFrame = Obj.Base.CFrame *CFrame.new(0,-50,0)
		end
	end)
	Obj.Trigger.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) and picked_up == false and ringing == false then
			ringing = true
			Obj.PhoneModel.WeldingPart.PhoneRing:Play()
			awaitinput()
			local stopwalls = Obj.Stoppers:GetChildren()
			for lol = 1, #stopwalls do
				stopwalls[lol].CanCollide = true
			end
		end
	end)
end

local function DoorEvents(Door)
	local RegisteredTouch = false
	Door.Inner.Union.Touched:Connect(function(p)
		if RegisteredTouch == false then
			RegisteredTouch = true
			local plr = game.Players:GetPlayerFromCharacter(p.Parent)
			if plr and Door.CustomLock.Value == true then
				RepStorage.Splash:FireClient(plr, "This door seems to be locked, maybe there's a key nearby?")
			end
			if plr and Door.CustomLock.Value == false and Door.Inner.Union.Anchored == true and Door.Unopenable.Value == false and Door.EventLock.Value == false then
				local Clone = script.door_unlock:Clone()
				Clone.Parent = Door.Inner.Union
				wait(.05)
				Clone:Play()
				wait(1.5)
				Door.Inner.Union.Anchored = false
				Clone:Destroy()
			end
			if plr and Door.Unopenable.Value == true then
				if Door.Unopenable:FindFirstChild("WhiteDoor") then
					RepStorage.Splash:FireClient(plr, "This isn't the way to the garage...")
				else
					RepStorage.Splash:FireClient(plr, "This door is wedged shut, I'm not opening it anytime soon.")
				end
			end
			wait(0.25)
			RegisteredTouch = false
		end
	end)
end

local function MetalDoorEvents(MyModel)
	local DoorOpen = false
	local Debounce = true
	local function OpenDoors()
		MyModel.Hitbox.DoorOpen:Play()
		DoorOpen = true
		MyModel.Light.BrickColor = BrickColor.new("Lime green")
		wait(0.13)
		local mytween = TweenService:Create(MyModel.Door1,TweenInfo.new(0.55,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = MyModel.Door1P2.Position})
		local mytween2 = TweenService:Create(MyModel.Door2,TweenInfo.new(0.55,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = MyModel.Door2P2.Position})
		mytween:Play()
		mytween2:Play()
	end
	local function CloseDoors()
		DoorOpen = false
		MyModel.Light.BrickColor = BrickColor.new("Really red")
		local mytween = TweenService:Create(MyModel.Door1,TweenInfo.new(0.8,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = MyModel.Door1P1.Position})
		local mytween2 = TweenService:Create(MyModel.Door2,TweenInfo.new(0.8,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = MyModel.Door2P1.Position})
		mytween:Play()
		mytween2:Play()
	end
	MyModel.Hitbox.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) and Debounce and MyModel.PanicDoor.Value == false then
			Debounce = false
			if MyModel.CustomLock.Value == false then
				local mycor = coroutine.wrap(function()
					OpenDoors()
					wait(4.5)
					CloseDoors()
					wait(0.625)
					Debounce = true
				end)
				mycor()
			else
				RepStorage.Splash:FireClient(game.Players:GetPlayerFromCharacter(part.Parent), "This door seems to be locked, maybe there's a keycard nearby?")
				wait(0.8)
				Debounce = true
			end
		end
	end)
	MyModel:WaitForChild("Open").Event:Connect(function()
		OpenDoors()
	end)
	MyModel:WaitForChild("Close").Event:Connect(function()
		CloseDoors()
	end)
end

local function AmbientEvents(MyBlock)
	local tappd = false
	MyBlock.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) and tappd == false then
			tappd = true
			MyBlock.SoundBlock.Audio:Play()
		end
	end)
end

local function LockerEvents(MyLocker)
	local open = false
	local debouncer = true
	game:GetService("ReplicatedStorage").Locker.OnServerEvent:Connect(function(plr,LockerModel)
		if MyLocker == LockerModel then
			if debouncer == true then
				debouncer = false
				if open == false then
					LockerModel.Base.LockerOpen:Play()
					if PlayerInALocker == true then
						PlayerInALocker = false
						script.InLocker:Fire()
						plr.Character.Head.CFrame = LockerModel.MagnitudeCheck.CFrame
						local c = EaI.LockerWalls.LockerWall:GetChildren()
						for i = 1, #c do
							c[i].Transparency = 1
						end
					end
					if LockerModel.Name == "Locker" then
						for i=1, math.abs(-15/2) do
							LockerModel:SetPrimaryPartCFrame(LockerModel.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/-11.25,0))
							wait()
						end
					elseif LockerModel.Name == "Vent" then
						for i=1, math.abs(-15/2) do
							LockerModel:SetPrimaryPartCFrame(LockerModel.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/-11.25,0))
							wait()
						end
					end
					open = true
				elseif open == true then
					LockerModel.Base.LockerClose:Play()
					if LockerModel.Name == "Locker" then
						for i=1, math.abs(-15/2) do
							LockerModel:SetPrimaryPartCFrame(LockerModel.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,-1*math.pi/-11.25,0))
							wait()
						end
					elseif LockerModel.Name == "Vent" then
						for i=1, math.abs(-15/2) do
							LockerModel:SetPrimaryPartCFrame(LockerModel.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,-1*math.pi/-11.25,0))
							wait()
						end
					end
					local magnitude = (plr.Character.Head.Position - LockerModel.MagnitudeCheck.Position).magnitude
					if magnitude <= 3 then
						PlayerInALocker = true
						script.InLocker:Fire()
						RepStorage.Locker:FireClient(plr,LockerModel.Subj.Value,LockerModel.Origi.Value,LockerModel)
						plr.Character.Head.CFrame = workspace.Building.Box.TpBox.CFrame
						local c = EaI.LockerWalls.LockerWall:GetChildren()
						wait(0.2)
						for i = 1, #c do
							c[i].Transparency = 0
						end
						RepStorage.Splash:FireClient(plr, "Click to exit.")
					end
					open = false
				end
				wait(0.05)
				debouncer = true
			end
		end
	end)
end

local function KeyEvents(KeyModel)
	local KeyTouched = false
	KeyModel.Hitbox.Touched:Connect(function(Touch)
		local plr = game.Players:GetPlayerFromCharacter(Touch.Parent)
		if plr and KeyTouched == false then
			KeyTouched = true
			if KeyModel.Trigger.Value == 1 then
				---this was used to play music on the radio but thanks to stupid roblox didnt work
			elseif KeyModel.Trigger.Value == 2 then
				FlashlightEvent(plr,true)
			elseif KeyModel.Trigger.Value == 3 then
				FinalKeyPickedUp = true
			end
			KeyModel.Item.Value.CustomLock.Value = false
			if KeyModel.UIandSound.Value == true then
				RepStorage.Splash:FireClient(plr, "I wonder what this unlocks...")
				local clone = script.key_pickup:Clone()
				clone.Parent = KeyModel.PhysicalKey
				clone:Play()
			elseif KeyModel.EndSound.Value == true then
				local clone = script.key_pickup:Clone()
				clone.Parent = KeyModel.PhysicalKey
				clone.Volume = 0.7
				clone:Play()
			end
			KeyModel.PhysicalKey.Transparency = 1
			wait(1.35)
			KeyModel:Destroy()
			wait(1)
			KeyTouched = false
		end
	end)
end

local function TextEvents(TextModel)
	local Read = false
	TextModel.Touched:Connect(function(Touch)
		local plr = game.Players:GetPlayerFromCharacter(Touch.Parent)
		if plr and Read == false then
			Read = true
			RepStorage.Splash:FireClient(plr, TextModel.Text.Value)
			if TextModel.Single.Value == false then
				wait(3)
				Read = false
			else
				TextModel:Destroy()
			end
		end
	end)
end

local function BarEvents(Bar)
	local bardebounce = false
	Bar.Touched:Connect(function(part)
		if bardebounce == false and game.Players:GetPlayerFromCharacter(part.Parent) then
			bardebounce = true
			RepStorage.Bars:FireClient(game.Players:GetPlayerFromCharacter(part.Parent),Bar.Option.Value)
			wait(1)
			bardebounce = false
		end
	end)
end

local function NoteEvents(MyNotebook)
	local NotesToPick = MyNotebook.NoteToPick.Value
	local notedebounce = true
	MyNotebook.Hitbox.Touched:Connect(function(part)
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr and notedebounce then
			notedebounce = false
			RepStorage.Note:FireClient(plr,NotesToPick)
			BadgeServ:AwardBadge(plr.UserId,2124476486)
			wait(2)
			notedebounce = true
		else
			wait(1)
		end
	end)
	MyNotebook.Close.Touched:Connect(function(part)
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr then
			RepStorage.Note:FireClient(plr,"Close")
		end
	end)
end

local SoundEventTriggered = false
local function StartAEvents(Block)
	Block.Touched:Connect(function(part)
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr and SoundEventTriggered == false then
			SoundEventTriggered = true
			local Sounds = Block:GetChildren()
			for i = 1, #Sounds do
				if Sounds[i]:IsA("ObjectValue") then
					Sounds[i].Value:Pause()
					if Sounds[i].Value:FindFirstChild("ReturnToScript") then
						Sounds[i].Value.Parent = script
						Sounds[i].Value:FindFirstChild("ReturnToScript"):Destroy()
					end
				end
			end
			SoundEventTriggered = false
		end
	end)
end

local function StopAEvents(Block)
	Block.Touched:Connect(function(part)
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr and SoundEventTriggered == false then
			SoundEventTriggered = true
			local Sounds = Block:GetChildren()
			for i = 1, #Sounds do
				if Sounds[i]:IsA("ObjectValue") and Sounds[i].Value.Playing == false then
					local normalvol = Sounds[i].Value.Volume
					local doaudioloop = coroutine.wrap(function(sound,normalvo)
						for i = 0, normalvol, 0.05 do
							sound.Value.Volume = i
							wait(0.0125)
						end
						sound.Value.Volume = normalvo
					end)
					doaudioloop(Sounds[i],normalvol)
					Sounds[i].Value:Resume()
					if Sounds[i].Value.Parent == script then
						Sounds[i].Value.Parent = workspace
						local m = Instance.new("SunRaysEffect")
						m.Parent = Sounds[i].Value
						m.Name = "ReturnToScript"
					end
				end
			end
			SoundEventTriggered = false
		end
	end)
end

local function HandleSteamEvent(part,side)
	if LockedSteam == false and game.Players:GetPlayerFromCharacter(part.Parent) then
		if side == SteamOn and SteamOn == "First" and side == "First" then
			SteamOn = "Second"
		elseif side == SteamOn and SteamOn == "Second" and side == "Second" then
			LockedSteam = true
			local steambloc = EaIC.SteamBlock
			steambloc:FindFirstChild("Trigger").Enabled = true
			steambloc.steam:Play()
			wait(1.75)
			steambloc:FindFirstChild("Trigger").Enabled = false
			steambloc.steam:Stop()
		end
	end
end

--[[  Coroutines  ]]--

local StartCameraLoop = coroutine.wrap(function()
	while HasGameStarted == false do
		wait(0.8)
		local num = math.random(1,2)
		local num2 = math.random(1,2)
		if num == 2 then
			num = -1
		end
		if num2 == 2 then
			num2 = -1
		end
		if TheSpecialValX+num == 5 or TheSpecialValX+num == -5 then
			num = num*-1
		end
		TheSpecialValX = TheSpecialValX+num
		if SpecialValY+num2 == 5 or SpecialValY+num2 == -5 then
			num2 = num2*-1
		end
		SpecialValY = SpecialValY+num2
		Menu_CFVal.Value=BaseCFrame*CFrame.fromEulerAnglesXYZ((TheSpecialValX*math.pi/180)/2,(SpecialValY*math.pi/180)/2,0)
		workspace.Cameras.CamModel:SetPrimaryPartCFrame(Menu_CFVal.Value)
	end
end)

local TheFallScene = coroutine.wrap(function()
	local WallLights = FallScene.PostLights.WallLights:GetChildren()
	local PostLights = FallScene.PostLights.NeonPosts:GetChildren()
	local InnerLights = FallScene.InnerLights:GetChildren()
	local function AllLightsOn()
		for _,v in pairs(WallLights) do
			v.Material = Enum.Material.Neon
			v.BrickColor = BrickColor.White()
			v.SpotLight.Enabled = true
		end
		for _,v in pairs(PostLights) do
			v.Material = Enum.Material.Neon
			v.BrickColor = BrickColor.White()
			v.SpotLight.Enabled = true
		end
		for _,v in pairs(InnerLights) do
			v.SpotLight.Enabled = false
		end
	end
	local function AllLightsOff()
		for _,v in pairs(WallLights) do
			v.Material = Enum.Material.SmoothPlastic
			v.BrickColor = BrickColor.Black()
			v.SpotLight.Enabled = false
		end
		for _,v in pairs(PostLights) do
			v.Material = Enum.Material.SmoothPlastic
			v.BrickColor = BrickColor.Black()
			v.SpotLight.Enabled = false
		end
		for _,v in pairs(InnerLights) do
			v.SpotLight.Enabled = false
		end
	end
	FallScene.FallTrigger.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) and FallSceneActivated == false then
			FallSceneActivated = true
			FallScene.Bridge.SoundPart.metal_break:Play()
			local BridgeFallObj = FallScene.Bridge:Clone()
			for _,v in pairs(FallScene.Bridge:GetChildren()) do v.Transparency = 1 if v:FindFirstChild("Texture") then v.Texture.Transparency = 1 v.Texture2.Transparency = 1 end end 
			BridgeFallObj.Parent = EaI.ClonesToRemove
			FallScene.Bridge.SoundPart.CanCollide = false
			BridgeFallObj.SoundPart.Anchored = false			
			FallScene.NoReturnBlock.CanCollide = true
			
			local LightFreakout = coroutine.wrap(function()
				repeat
					wait(0.08)
					local Obj1 = WallLights[math.random(1,#WallLights)]
					local Obj2 = PostLights[math.random(1,#PostLights)]
					local Obj3 = InnerLights[math.random(1,#InnerLights)]
					if Obj1.Material == Enum.Material.Neon then
						Obj1.Material = Enum.Material.SmoothPlastic
						Obj1.BrickColor = BrickColor.Black()
						Obj1.Sound:Play()
					else
						Obj1.Material = Enum.Material.Neon
						Obj1.BrickColor = BrickColor.White()
					end
					if Obj2.Material == Enum.Material.Neon then
						Obj2.Material = Enum.Material.SmoothPlastic
						Obj2.BrickColor = BrickColor.Black()
						Obj2.Sound:Play()
					else
						Obj2.Material = Enum.Material.Neon
						Obj2.BrickColor = BrickColor.White()
					end
					Obj1.SpotLight.Enabled = not Obj1.SpotLight.Enabled
					Obj2.SpotLight.Enabled = not Obj2.SpotLight.Enabled
					Obj3.SpotLight.Enabled = not Obj3.SpotLight.Enabled
				until FallScenePlayerSafe or FallSceneTimeCount <= 0
				coroutine.yield()
			end)
			LightFreakout()
			repeat
				wait(1)
				FallSceneTimeCount = FallSceneTimeCount - 1
			until FallScenePlayerSafe or FallSceneTimeCount <= 0
			AllLightsOff()
			script.BridgeDoor.Value.Open:Fire()
			if FallScenePlayerSafe == true then
				wait(2)
				AllLightsOn()
			else
				FallScene.WallBlock.CanCollide = true
				wait(1.2)
				HandleDeath(game.Players:GetPlayerFromCharacter(part.Parent),"Bridge")
			end
		end
	end)
	FallScene.SafetyBlock.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) then
			FallScenePlayerSafe = true
			FallScene.WallBlock.CanCollide = true
		end
	end)
	script.FixFallScene.Event:Connect(function()
		AllLightsOn()
		for _,v in pairs(FallScene.Bridge:GetChildren()) do v.Transparency = 0 if v:FindFirstChild("Texture") then v.Texture.Transparency = 0 v.Texture2.Transparency = 0 end end 
		FallScene.Bridge.SoundPart.CanCollide = true
		FallScene.NoReturnBlock.CanCollide = false
		FallScene.WallBlock.CanCollide = false
		script.BridgeDoor.Value.Close:Fire()
	end)
end)

local EyeLoops = coroutine.wrap(function()
	local EyeLoopNum = math.random(1,14)/10
	local myeyes = EaIC.EyePairs:GetChildren()

	while wait(EyeLoopNum) do
		EyeLoopNum = math.random(4,14)/10
		local eyetoget = myeyes[math.random(1,#myeyes)]:GetChildren()
		for i = 1, #eyetoget do
			eyetoget[i].BrickColor = BrickColor.Black()			
		end
		wait(0.08)
		for i = 1, #eyetoget do
			eyetoget[i].BrickColor = BrickColor.White()			
		end
	end
end)

local FlashlightObj = coroutine.wrap(function()
	while wait(math.random(1,5)) do
		local mylightitem = EaIC.Flashlight.Model
		local mylightitem2 = EaIC.Flashlight2.Model
		local k = math.random(1,3)
		if k == 1 then
			mylightitem.Light.SpotLight.Enabled = false
			mylightitem.Light.BrickColor = BrickColor.Black()
			mylightitem.Light.Material = Enum.Material.SmoothPlastic
			mylightitem.LightPart.Beam.Enabled = false
			
			mylightitem2.Light.SpotLight.Enabled = false
			mylightitem2.Light.BrickColor = BrickColor.Black()
			mylightitem2.Light.Material = Enum.Material.SmoothPlastic
			mylightitem2.LightPart.Beam.Enabled = false
		else
			mylightitem.Light.SpotLight.Brightness = 5
			mylightitem.Light.BrickColor = BrickColor.Gray()
			mylightitem.LightPart.Beam.Color = ColorSequence.new(Color3.fromRGB(111,111,111),Color3.fromRGB(111,111,111))
			
			mylightitem2.Light.SpotLight.Brightness = 5
			mylightitem2.Light.BrickColor = BrickColor.Gray()
			mylightitem2.LightPart.Beam.Color = ColorSequence.new(Color3.fromRGB(111,111,111),Color3.fromRGB(111,111,111))
		end
		wait(.15)
		mylightitem.LightPart.Beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
		mylightitem.Light.SpotLight.Brightness = 10
		mylightitem.Light.SpotLight.Enabled = true
		mylightitem.Light.BrickColor = BrickColor.White()
		mylightitem.Light.Material = Enum.Material.Neon
		mylightitem.LightPart.Beam.Enabled = true
		
		mylightitem2.LightPart.Beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
		mylightitem2.Light.SpotLight.Brightness = 10
		mylightitem2.Light.SpotLight.Enabled = true
		mylightitem2.Light.BrickColor = BrickColor.White()
		mylightitem2.Light.Material = Enum.Material.Neon
		mylightitem2.LightPart.Beam.Enabled = true
	end
end)
FlashlightObj()

local LightFlickerLop = coroutine.wrap(function()
	while wait(0.25) do
		if CornerLightFlicker == true then
			while CornerLightFlicker == true do
				local things = script.SpookyLight.Value:GetChildren()
				for i = 1, #things do
					things[i].LightObj.Brightness = 0.75
				end
				wait(0.1)
				for i = 1, #things do
					things[i].LightObj.Brightness = 0.5
				end
				wait(0.1)
				for i = 1, #things do
					things[i].LightObj.Brightness = 0.25
				end
				wait(0.1)
				for i = 1, #things do
					things[i].LightObj.Brightness = 0.5
				end
				wait(0.1)
				for i = 1, #things do
					things[i].LightObj.Brightness = 0.75
				end
				wait(0.1)
				for i = 1, #things do
					things[i].LightObj.Brightness = 1
				end
				wait(0.1)
			end
		else
			wait(0.1)
		end
	end
end)

1639-2861:


local RandomLightFlicker = coroutine.wrap(function()
	while wait(math.random(1,24)/10) do
		local LightsToFlick = EaI.LightGroups:GetChildren()
		local AllOn = true
		local Conf_Light = nil
		repeat		
			local mylight = LightsToFlick[math.random(1,#LightsToFlick)]:GetChildren()
			AllOn = true
			Conf_Light = mylight
			for i, v in pairs(mylight) do
				local x
				if v:FindFirstChildWhichIsA("PointLight") then
					x = "PointLight"
				elseif v:FindFirstChildWhichIsA("SpotLight")then
					x = "SpotLight"
				end
				if x then
					x = v:FindFirstChildWhichIsA(x)
					if x.Brightness ~= 0 and x.Enabled ~= false and x.Range ~= 0 then
						AllOn = false
					end
				end
			end
			wait()
		until not AllOn == true and Conf_Light ~= nil 
		for i, v in pairs(Conf_Light) do
			local x
			if v:FindFirstChildWhichIsA("PointLight") then
				x = "PointLight"
			elseif v:FindFirstChildWhichIsA("SpotLight")then
				x = "SpotLight"
			end
			wait()
			if x then
				x = v:FindFirstChildWhichIsA(x)
				if x.Brightness ~= 0 and x.Enabled ~= false and x.Range ~= 0 then
					x.Brightness = x.Brightness/3
				end
			end
		end
		wait(0.6)
		for i, v in pairs(Conf_Light) do
			local x
			if v:FindFirstChildWhichIsA("PointLight") then
				x = "PointLight"
			elseif v:FindFirstChildWhichIsA("SpotLight")then
				x = "SpotLight"
			end
			if x then
				x = v:FindFirstChildWhichIsA(x)
				if x.Brightness ~= 0 and x.Enabled ~= false and x.Range ~= 0 then
					x.Brightness = x.Brightness*3
				end
			end
		end
	end
end)

local CutScene1 = coroutine.wrap(function(plr)
	wait(.2)
	for i=1, math.abs(-12/2) do
		wait()
		EaIC.Shelf:SetPrimaryPartCFrame(EaIC.Shelf.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi/-12))
	end
	RepStorage.Shake:FireClient(plr, true)
	EaIC.Shelf.SoundPart.ShelfFall:Play()
	
	EaI.Particles.DustFallParticle.ParticleEmitter.Enabled = true
	wait(.35)
	EaI.Particles.DustFallParticle.ParticleEmitter.Enabled = false
	wait(.4)
	RepStorage.Shake:FireClient(plr,false)
end)

local CutScene2 = coroutine.wrap(function(plr,obj)
	plr.Character.Humanoid.WalkSpeed = 0
	wait(0.65)
	mks = script.LightsFlicker:Clone()
	mks.Parent = workspace
	mks:Play()
	local c = obj:GetChildren()
	for i = 1, #c do
		local lightloop = coroutine.wrap(function(brick)
			if brick:FindFirstChild("LightObj") then
				local lightbaseval = brick.LightObj.Brightness
				brick.LightObj.Brightness = lightbaseval/8
				wait(0.05)
				brick.LightObj.Brightness = lightbaseval/5
				wait(0.05)
				brick.LightObj.Brightness = lightbaseval/10
				wait(1.25)
				for i = lightbaseval/10, lightbaseval,0.025 do
					wait(0.05)
					brick.LightObj.Brightness = i
				end
				brick.LightObj.Brightness = lightbaseval
			end
		end)
		lightloop(c[i])
	end
	wait(0.25)
	for i = 4, 0, -0.2 do
		wait(0.07)
		mks.Volume = i
	end
	mks.Volume = 0
	mks:Destroy()
	wait(2)
	--RepStorage.Splash:FireClient(plr, "The place is old, power is probably running low.")
	plr.Character.Humanoid.WalkSpeed = 14
end)

local Cutscene3 = coroutine.wrap(function(plr)
	plr.Character.Humanoid.WalkSpeed = 0
	RepStorage.Bookshelf:FireClient(plr)
	local musicstop = coroutine.wrap(function()
		local audio = game.Workspace:FindFirstChild("Ost1")
		if audio then
			audio:Destroy()
		end
	end)
	musicstop()
	wait(0.6)
	RepStorage.Splash:FireClient(plr, "..!")
	wait(0.6)
	--camera events
	local bookshelf = EaIC.CutsceneBook
	tweenModel(bookshelf.Shelf,bookshelf.ShouldBe.CFrame,2)
	local c = script.bookshelf:Clone()
	c.Parent = bookshelf.Shelf.Union
	c:Play()
	RepStorage.Shake:FireClient(plr, true)
	wait(5)
	RepStorage.Shake:FireClient(plr,false)
	c:Destroy()
	wait(1)
	plr.Character.Humanoid.WalkSpeed = 14
	local gonein = false
	EaIC.HoleBlock.Touched:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) and gonein == false then
			part.Parent.Humanoid.WalkSpeed = 0
			gonein = true
			RepStorage.Splash:FireClient(plr, "I should only go in if I'm sure that I've seen everything here, I might not be coming back.")
			wait(5)
			part.Parent.Humanoid.WalkSpeed = 14
		end
	end)
end)

local rotatethegod = coroutine.wrap(function()
	local parts = EaIC:WaitForChild("racer6743"):GetChildren()
	for m = 1, #parts do
		if parts[m]:IsA("BasePart") then
			wait(2)
			PhysicsService:SetPartCollisionGroup(parts[m], "Barriers")
		end
	end
	while wait(3) do
		if RotatingRacer == true then
			while wait(0.01) and RotatingRacer do
				local myracer = EaIC:WaitForChild("racer6743")
				local mytween = TweenService:Create(myracer.HumanoidRootPart,TweenInfo.new(0.01,Enum.EasingStyle.Linear),{CFrame = myracer.HumanoidRootPart.CFrame*CFrame.Angles(0,math.rad(1),0)})
				mytween:play()
			end
		end
	end
end)
rotatethegod()

--[[  Events  ]]--

local meme = false
game.Workspace.Building.Second_section.SpecialBookshelf.MemeThing.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and meme == false then
		meme = true
		wait(0.5)
		RepStorage.Meme:FireClient(plr)
		wait(2)
		plr.Character.HumanoidRootPart.CFrame = workspace.Building.Second_section.SpecialBookshelf.Tp.CFrame
		game.Workspace.Building.Second_section.SpecialBookshelf.MemeThing.CanCollide = true
	end
end)

EaIC.Ch3End.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr then
		BadgeServ:AwardBadge(plr.UserId,2124481706)
	end
end)

local PitDebounce = false
EaIC.TriggerPit.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and PitDebounce == false then
		local Eyething = EaIC.PitEyes
		PitDebounce = true
		local aud = script.Hey:Clone()
		aud.Parent = workspace
		aud:Play()
		for i = 1, 50 do
			Eyething.CFrame = Eyething.CFrame * CFrame.new(0,-0.75,0)
			wait(0.001)
		end
		wait(3.1)
		aud:Destroy()
	end
end)

local FBDebounce = true
EaIC.TheFinalBrick.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and FBDebounce == true then
		FBDebounce = false
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		local mytween = TweenService:Create(game.Lighting,TweenInfo.new(8,Enum.EasingStyle.Linear),{ClockTime = 7, OutdoorAmbient = Color3.fromRGB(216,208,192)})
		mytween:Play()
		EaIC.BirdThing.Chirping:Play()
		wait(3.5)
		local riseaudio = script.Riser:Clone()
		riseaudio.Parent = workspace
		riseaudio:Play()
		wait(4.34)
		BadgeServ:AwardBadge(plr.UserId,2124497262)
		if TrueEnding == true then
			RepStorage.RollCredits:FireClient(plr,"True")
			BadgeServ:AwardBadge(plr.UserId,2124497266)
		else
			RepStorage.RollCredits:FireClient(plr,"Good")
			BadgeServ:AwardBadge(plr.UserId,2124497265)
		end
		EaIC.BirdThing.Chirping:Stop()
		if workspace:FindFirstChild("WindAmbience") then
			workspace.WindAmbience:Stop()
		end
		plr.Character.Humanoid.WalkSpeed = 0
		plr.Character.Humanoid.JumpPower = 0
	end
end)

EaIC.Chapter3WindowOn.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		EaIC.SpookyDooky.Decal.Transparency = 0
		EaIC.SpookyDooky.SurfaceLight.Enabled = true
	end
end)

EaIC.BadEndTouchpart.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and EndGame == false then
		EndGame = true
		workspace.Sounds.GlitchNoise1:Stop()
		workspace.Sounds.GlitchNoise2:Stop()
		part.Parent.Humanoid.WalkSpeed = 11
		
		RepStorage.ActivateEnd:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
		wait(0.25)
		SoundServ.AmbientReverb = Enum.ReverbType.StoneRoom
		part.Parent.HumanoidRootPart.CFrame = EaIC.TeleportBadEnd.CFrame
	end
end)

EaIC.BadEnd.Light1.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.Light1.LightObj and EaIC.BadEnd.Light1.LightObj.Enabled == false then
		EaIC.BadEnd.Light1.SpotLightOn:Play()
		wait(0.2)
		EaIC.BadEnd.Light1.LightObj.Enabled = true
		workspace.Sounds.SuperSuspense.Volume = 0
		
		local voltoset = 0.2
		local pitchtoset = 1
		local myloop1 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.Volume, voltoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.Volume = i
			end
		end)
		local myloop2 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.PlaybackSpeed, pitchtoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.PlaybackSpeed = i
			end
		end)
		myloop1()
		myloop2()
		
		workspace.Sounds.SuperSuspense:Play()
	end
end)
EaIC.BadEnd.Light2.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.Light2.LightObj and EaIC.BadEnd.Light2.LightObj.Enabled == false then
		EaIC.BadEnd.Light2.SpotLightOn:Play()
		wait(0.2)
		EaIC.BadEnd.Light2.LightObj.Enabled = true
		local voltoset = 0.3
		local pitchtoset = 1.2
		local myloop1 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.Volume, voltoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.Volume = i
			end
		end)
		local myloop2 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.PlaybackSpeed, pitchtoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.PlaybackSpeed = i
			end
		end)
		myloop1()
		myloop2()
	end
end)

EaIC.BadEnd.Light3.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.Light3.LightObj and EaIC.BadEnd.Light3.LightObj.Enabled == false then
		EaIC.BadEnd.Light3.SpotLightOn:Play()
		wait(0.2)
		EaIC.BadEnd.Light3.LightObj.Enabled = true
		local voltoset = 0.4
		local pitchtoset = 1.4
		local myloop1 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.Volume, voltoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.Volume = i
			end
		end)
		local myloop2 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.PlaybackSpeed, pitchtoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.PlaybackSpeed = i
			end
		end)
		myloop1()
		myloop2()
	end
end)
EaIC.BadEnd.Light4.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.Light4.LightObj and EaIC.BadEnd.Light4.LightObj.Enabled == false then
		EaIC.BadEnd.Light4.SpotLightOn:Play()
		wait(0.2)
		EaIC.BadEnd.Light4.LightObj.Enabled = true
		local voltoset = 0.5
		local pitchtoset = 1.6
		local myloop1 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.Volume, voltoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.Volume = i
			end
		end)
		local myloop2 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.PlaybackSpeed, pitchtoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.PlaybackSpeed = i
			end
		end)
		myloop1()
		myloop2()
	end
end)

EaIC.LastCodeHitbox.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		local myitemtofire = RepStorage:FindFirstChild("OpenLastCode")
		myitemtofire:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
	end
end)

EaIC.LastCodeDisable.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		local myitemtofire = RepStorage:FindFirstChild("CloseLastCode")
		myitemtofire:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
	end
end)

EaIC.BadEnd.Light5.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.Light5.LightObj and EaIC.BadEnd.Light5.LightObj.Enabled == false then
		EaIC.BadEnd.Light5.SpotLightOn:Play()
		wait(0.2)
		EaIC.BadEnd.Light5.LightObj.Enabled = true
		local voltoset = 0.6
		local pitchtoset = 1.8
		local myloop1 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.Volume, voltoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.Volume = i
			end
		end)
		local myloop2 = coroutine.wrap(function()
			for i = workspace.Sounds.SuperSuspense.PlaybackSpeed, pitchtoset, 0.025 do
				wait(0.02)
				workspace.Sounds.SuperSuspense.PlaybackSpeed = i
			end
		end)
		myloop1()
		myloop2()
	end
end)

RepStorage.KeySlot.OnServerEvent:Connect(function(plr)
	if KeyDebounce and FinalKeyPickedUp == true then
		KeyDebounce = false
		EaI.KeySlots.KeySlot.Base.CFrame = EaI.KeySlots.KeySlot.Base.CFrame*CFrame.new(0,-25,0)
		local mytween = TweenService:Create(EaI.KeySlots.KeySlot.KeyPart,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = EaI.KeySlots.KeySlot.KeyPartReference.Position, Transparency = 0})
		mytween:Play()
		wait(0.6)
		EaIC.Monitor1.Part.SurfaceGui.Key.Value = true
		EaIC.Monitor1.Part.SurfaceGui.TX1.Text = "Saftey Key | ✓"
		wait(0.35)
		RunFinalCheck()
	end
end)

RepStorage.FinalCodeEntered.OnServerEvent:Connect(function(plr)
	if CodeDebounce then
		CodeDebounce = false
		EaIC.Monitor1.Part.SurfaceGui.Code.Value = true
		EaIC.Monitor1.Part.SurfaceGui.TX3.Text = "Confirmation Code | ✓"
		wait(0.35)
		RunFinalCheck()
	end
end)

EaIC.BadEnd.FinalBulb.Trigger.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr and EaIC.BadEnd.FinalBulb.Bulb.LightObj and EaIC.BadEnd.FinalBulb.Bulb.LightObj.Enabled == false and GameEnded == false then
		EaIC.BadEnd.FinalBulb.Bulb.LightObj.Enabled = true
		GameEnded = true
		EaIC.BadEnd.FinalBulb.Light.Material = Enum.Material.Neon
		workspace.Sounds.SuperSuspense:Stop()
		plr.Character.Humanoid.WalkSpeed = 0
		wait(3)
		EaIC.EyePair.Part.Transparency = 0
		EaIC.EyePair.Part2.Transparency = 0
		wait(0.04)
		EaIC.EyePair.Part.Transparency = 1
		EaIC.EyePair.Part2.Transparency = 1
		wait(0.09)
		EaIC.EyePair.Part.Transparency = 0
		EaIC.EyePair.Part2.Transparency = 0
		wait(1.85)
		BadgeServ:AwardBadge(plr.UserId,2124497262)
		BadgeServ:AwardBadge(plr.UserId,2124497264)
		RepStorage.RollCredits:FireClient(plr,"Bad")
		EaIC.EyePair.Part.Transparency = 1
		EaIC.EyePair.Part2.Transparency = 1
		EaIC.BadEnd.FinalBulb.Bulb.LightObj.Enabled = false
		EaIC.BadEnd.FinalBulb.Light.Material = Enum.Material.SmoothPlastic
		workspace.Sounds.gameLightLast:Play()
	end
end)

EaIC.Chapter3WindowOff.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		EaIC.SpookyDooky.Decal.Transparency = 1
		EaIC.SpookyDooky.SurfaceLight.Enabled = false
	end
end)
local pianogood2go = true
RepStorage.Piano.OnServerEvent:Connect(function(plr,thing)
	if pianogood2go == true then
		pianogood2go = false
		local mynum = math.random(1,50)
		if mynum ~= 50 then
			local c = script.piano:Clone()
			c.Parent = thing.Base
			c:Play()
			wait(0.4)
			c:Destroy()
		else
			local c = script.piano:Clone()
			c.Parent = workspace
			c:Play()
			wait(0.16)
			local f = script.piano:Clone()
			f.Parent = workspace
			f:Play()
			wait(0.16)
			local h = script.piano:Clone()
			h.Parent = workspace
			h.PlaybackSpeed = 2.1
			h:Play()
			wait(0.24)
			local j = script.piano:Clone()
			j.Parent = workspace
			j.PlaybackSpeed = 1.45
			j:Play()
			wait(0.3)
			c:Destroy()
			f:Destroy()
			h:Destroy()
			j:Destroy()
		end
		wait(0.025)
		pianogood2go = true
	end
end)

RepStorage.EndgamePanel.OnServerEvent:Connect(function(Plr,MyObj)
	if MyObj.Activated.Value == false then
		MyObj.Activated.Value = true
		MyObj.Light.BrickColor = BrickColor.new("Really red")
		workspace.Sounds.EngineOff:Play()
		workspace.Sounds.LeverPull:Play()
		MyObj.Light.PointLight.Color = Color3.fromRGB(255,60,0)
		local LightsToTurnOff = MyObj.Lights:GetChildren()
		for i = 1, #LightsToTurnOff do
			LightsToTurnOff[i].BrickColor = BrickColor.new("Black")
			LightsToTurnOff[i].Material = Enum.Material.SmoothPlastic
		end
		local MyLever = MyObj.LeverOff:GetChildren()
		local MyLever2 = MyObj.LeverOn:GetChildren()
		for i = 1, #MyLever do
			MyLever[i].Transparency = 0
			MyLever2[i].Transparency = 1
		end
		local mycor = coroutine.wrap(function()
			RepStorage.Shake:FireClient(Plr,true)
			wait(0.45)
			RepStorage.Shake:FireClient(Plr,false)
		end)
		mycor()
		DoPanelEvent(Plr,MyObj)
	end
end)

RepStorage.UploadNoteData.OnServerEvent:connect(function(plr,MyData)
	local success, errormsg = pcall(function()
		NotepadDatastore:SetAsync(plr.UserId.."-LBR",MyData)
	end)
	if success then
		print("Saved data successfuly!")
	end
end)

local function onRemovePlayerDataEvent(userID)
	-- Pattern for data store player key, for instance "Player_12345678"
	local dataStoreKey = userID.."-LBR"

	local success, err = pcall(function()
		return NotepadDatastore:RemoveAsync(dataStoreKey)
	end)
	if success then
		warn("Removed player data for user ID '" .. userID .. "'")
	else
		warn(err)
	end--game.ServerScriptService.ServerMainScript.removePlayerDataEvent:Fire(id) / erasure request
end
script.removePlayerDataEvent.Event:Connect(onRemovePlayerDataEvent)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local Humanoid = char:WaitForChild("Humanoid")
		local success, errormsg = pcall(function()
			Data = NotepadDatastore:GetAsync(plr.UserId.."-LBR")
		end)
		if success then
			RepStorage.UploadNoteData:FireClient(plr,Data)
		end
	end)
end)

EaIC.TriggerBlock1.Touched:Connect(function(blck)
	if game.Players:GetPlayerFromCharacter(blck.Parent) then
		if Cutscene2Trigger == 1 then
			Cutscene2Trigger = 2
			EaIC.TriggerBlock1:Destroy()
		end
	end
end)

EaIC.TriggerBlock2.Touched:Connect(function(blck)
	if game.Players:GetPlayerFromCharacter(blck.Parent) then
		if Cutscene2Trigger == 2 then
			Cutscene2Trigger = 3
			CutScene2(game.Players:GetPlayerFromCharacter(blck.Parent),EaIC.TriggerBlock2.Value.Value)
			EaIC.TriggerBlock2:Destroy()
		end
	end
end)
EaIC.MusicTriggerCh3Start.Touched:connect(function(blck)
	if game.Players:GetPlayerFromCharacter(blck.Parent) and Ch3MusicPlayed == false then
		Ch3MusicPlayed = true
		local MyAudio = script.ScaryAmbiance:Clone()
		MyAudio.Parent = workspace
		MyAudio:Play()
	end
end)

EaIC.MusicTriggerCh3Stop.Touched:connect(function(blck)
	if game.Players:GetPlayerFromCharacter(blck.Parent) and Ch3MusicPlayed == true then
		Ch3MusicPlayed = "DontPlay"
		local MyAudio = workspace:FindFirstChild("ScaryAmbiance")
		if MyAudio then
			for i = MyAudio.Volume, 0, -0.1 do
				wait(0.025)
				MyAudio.Volume = i
			end
			MyAudio:Destroy()
		end
	end
end)

EaIC.FourthNoteToggle.Touched:connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and ReadyToBeCornered == false and CorneredAlready == false then
		ReadyToBeCornered = true
	end
end)

EaIC.Ele.TriggerElevator.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and EleTouched == false then
		EleTouched = true
		part.Parent.Humanoid.WalkSpeed = 14
		local ele = EaIC.Ele
		RepStorage.Ele:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
		part.Parent.Humanoid.AutoRotate = false
		wait(1)
		local gyroclone = Instance.new("BodyGyro")
		gyroclone.Parent = part.Parent.HumanoidRootPart
		gyroclone.P = 6000
		gyroclone.MaxTorque = Vector3.new(40000000,50000,40000000)
		gyroclone.CFrame = EaIC.Ele.ThingToPointTo.CFrame
		wait(1.5)
		local thing = TweenService:Create(ele.Door1,TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = ele.Door1.Position + Vector3.new(2.9,0,0)})
		thing:Play()
		local thing2 = TweenService:Create(ele.Door2,TweenInfo.new(1.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = ele.Door2.Position - Vector3.new(2.9,0,0)})
		thing2:Play()
		wait(1.8)
		ele.SoundBit.beep:Play()
		gyroclone:Destroy()
		ele.DownArrow1.Material = Enum.Material.Neon
		ele.DownArrow1.BrickColor = BrickColor.new("Really red")
		ele.DownArrow2.Material = Enum.Material.Neon
		ele.DownArrow2.BrickColor = BrickColor.new("Really red")
		Chap3Thing(part)
	end
end)

EaIC.EnterCh4.Touched:connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and Chapter3EndActivated == false then
		RepStorage.Ch4Start:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
		wait(.8)
		Chapter3EndActivated = true
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		RepStorage.Ch3End:FireClient(plr)
		plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.Ch4WalkPart3.Position,EaIC.Ch4WalkPart3)
		wait(2)
		plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.Ch4WalkPart4.Position,EaIC.Ch4WalkPart4)
		wait(4)
		RepStorage.StartChapter:FireClient(plr,4)
	end
end)

EaIC.FourthNoteTrigger.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and ReadyToBeCornered == true and CorneredAlready == false then
		CorneredAlready = true
		CornerLightFlicker = true
		script.SpookyPart.Value.Inner.Union.Anchored = true
		script.SpookyPart.Value.EventLock.Value = true
		local myaudio = script.Bang:Clone()
		myaudio.Parent = script.SpookyPart.Value.Inner.Union
		myaudio:Play()
		local AudioCloned = script.Ost3:Clone()
		AudioCloned.Parent = workspace
		AudioCloned:Play()
		local msf = 0
		repeat
			wait(1)
			if msf == 15 then
				HandleDeath(game.Players:GetPlayerFromCharacter(part.Parent),"Monster")
				myaudio:Destroy()
				CornerLightFlicker = false
				AudioCloned:Destroy()
				break
			end
			msf = msf+1
		until PlayerInALocker == true
		if PlayerInALocker == true then
			local heartbeat = script.heart_beat:Clone()
			heartbeat.Parent = workspace
			heartbeat:Play()
			local heartloop = coroutine.wrap(function()
				for i = heartbeat.Volume, 0, -0.2 do
					wait(0.5)
					heartbeat.Volume = i
				end
				heartbeat:Destroy()
			end)
			heartloop()
			local DoorBreakAudio = script.door_break:Clone()
			DoorBreakAudio.Parent = script.SpookyPart.Value.Inner.Union
			DoorBreakAudio:Play()
			myaudio:Stop()
			local audioloop = coroutine.wrap(function()
				for i = AudioCloned.Volume, 0, -0.5 do
					wait(0.025)
					AudioCloned.Volume = i
				end
			end)
			audioloop()
			local deletedoor = coroutine.wrap(function()
				wait(3)
				DoorBreakAudio:Destroy()
				local DoorChildren = script.SpookyPart.Value.Inner:GetChildren()
				for DoorI = 1, #DoorChildren do
					DoorChildren[DoorI].Transparency = 1
					DoorChildren[DoorI].CanCollide = false
				end
	
			end)
			deletedoor()
			CornerLightFlicker = false
			local things = script.SpookyLight.Value:GetChildren()
			for i = 1, #things do
				things[i].LightObj.Enabled = false
				things[i].LightObj.Brightness = 0
			end
			local EventStillGoing = true
			local keepcheck = coroutine.wrap(function()
				repeat wait(.1) until PlayerInALocker == false
				if EventStillGoing == true then
					HandleDeath(game.Players:GetPlayerFromCharacter(part.Parent),"Monster")
				end
			end)
			keepcheck()
			wait(2.5)
			if PlayerInALocker == true then
				RepStorage.VentFlashScene:FireAllClients(true)
				wait(3)
				if PlayerInALocker == true then
					wait(3)
				end
				if PlayerInALocker == true then
					wait(3)
				end
				if PlayerInALocker == true then
					wait(3)
				end
			end
			EventStillGoing = false
			for brightlevel = 0, 0.75, 0.05 do
				wait(0.05)
				for i = 1, #things do
					things[i].LightObj.Enabled = true
					things[i].LightObj.Brightness = brightlevel
				end
			end
		end
	end
end)

local quickdebounce = true
game.ReplicatedStorage.Tween.OnServerEvent:Connect(function(plr,Pos)
	if Pos ~= "done" then
		if MoveThing == true then
			local MyPos = ExecuteFormula1(Pos)
			tweenModel(workspace.Building.MainMenu.Prim,MyPos)
			if Pos == 100 then
				MoveThing = false
				workspace.Building.MainMenu.Prim.PrimaryPart.FirstClick:Play()
			end
		end
	elseif Pos == "done" and quickdebounce then
		quickdebounce = false
		local Mypos = ExecuteFormula1(0)
		tweenModel(workspace.Building.MainMenu.Prim,Mypos)
		workspace.Building.MainMenu.Prim.PrimaryPart.SecondClick:Play()
		wait(1.2)
		BadgeServ:AwardBadge(plr.UserId,2124476489)		
	end
end)

game.ReplicatedStorage.TeleportToPos.OnServerEvent:Connect(function(plr,PositionPart)
	if PositionPart:IsDescendantOf(EaIC) then
		plr.Character.HumanoidRootPart.CFrame = PositionPart.CFrame
	end
end)

EaIC.CodeHitScreen.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr then
		RepStorage.Code:FireClient(plr,"Open")
		if EaIC.Screen.BrickColor == BrickColor.new("Black") then
			EaIC.Screen.BrickColor = BrickColor.new("White")
			EaIC.Screen.Material = Enum.Material.Neon
		end
	end
end)

local ch4end = false
EaIC.Ch4Badge.Touched:connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and ch4end == false then
		ch4end = true
		RepStorage.Ch4Start:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
		wait(0.8)
		if game.Workspace:FindFirstChild("ScaryAmbiance3") then
			workspace.ScaryAmbiance3:Destroy()
		end
		BadgeServ:AwardBadge(game.Players:GetPlayerFromCharacter(part.Parent).UserId,2124489285)
		part.Parent:WaitForChild("Humanoid"):MoveTo(EaIC.Ch4WalkPart5.Position,EaIC.Ch4WalkPart5)
		RepStorage.Ch4End:FireClient(game.Players:GetPlayerFromCharacter(part.Parent))
		wait(3)
		RepStorage.StartChapter:FireClient(game.Players:GetPlayerFromCharacter(part.Parent),5)
	end
end)

EaIC.StopCode.Touched:Connect(function(part)
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if plr then
		RepStorage.Code:FireClient(plr,"Close")
		if EaIC.Screen.BrickColor == BrickColor.new("Lime green") then
		else
			EaIC.Screen.BrickColor = BrickColor.new("Black")
			EaIC.Screen.Material = Enum.Material.Glass
		end
	end
end)

EaIC.ChangeHallway1.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and EaIC.LabHallway.Part.Transparency == 1 then
		local c = EaIC.LabHallway:GetChildren()
		for i = 1, #c do
			if c[i].Material ~= Enum.Material.Glass then
				c[i].Transparency = 0
			else
				c[i].Transparency = 0.75
			end
		end
	end
end)

EaIC.ChangeHallway2.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		local c = EaIC.LabHallway:GetChildren()
		for i = 1, #c do
			c[i].Transparency = 1
		end
	end
end)

EaIC.EscapeBadge.Touched:Connect(function(d)
	if game.Players:GetPlayerFromCharacter(d.Parent) then
		BadgeServ:AwardBadge(game.Players:GetPlayerFromCharacter(d.Parent).UserId,2124478750)
	end
end)

RepStorage.Code.OnServerEvent:Connect(function(plr,thing)
	if thing == "Yes" then
		EaIC.Screen.BrickColor = BrickColor.new("Lime green")
		EaIC.Screen.Material = Enum.Material.Neon
		Cutscene3(plr)
	elseif thing == "No" then
		EaIC.Screen.BrickColor = BrickColor.new("Really red")
		EaIC.Screen.Material = Enum.Material.Neon
		wait(1)
		if not EaIC.Screen.BrickColor == BrickColor.new("Black") then
			EaIC.Screen.BrickColor = BrickColor.new("White")
		end
	end
end)

EaIC.DecalVisibleBlock.Touched:connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		EaIC.DecalVisibleBlock:Destroy()
		EaIC.SignHallway.Decal.Transparency = 0
		local mksfg = false
		EaIC.HallwayCutsceneBrick.Touched:Connect(function(part2)
			if game.Players:GetPlayerFromCharacter(part2.Parent) and mksfg == false then
				mksfg = true
				local lightbois = EaIC.HallwayCutsceneBrick.Value.Value:GetChildren()
				for i = 1, #lightbois do
					if lightbois[i]:IsA("Part") then
						lightbois[i].LightObj.Enabled = false
					end
				end
				EaIC.HallwaySmile.Transparency = 0
				if workspace:FindFirstChild("Ost1") then
					workspace:FindFirstChild("Ost1").PlaybackSpeed = 15
				end
				wait(0.35)
				if workspace:FindFirstChild("Ost1") then
					workspace:FindFirstChild("Ost1").PlaybackSpeed = 1
				end
				local m = script.heart_beat:Clone()
				m.Parent = workspace
				m:Play()
				RepStorage:FindFirstChild("FOV_Distort"):FireClient(game.Players:GetPlayerFromCharacter(part.Parent), 85)
				local DecreaseVolume = coroutine.wrap(function()
					for i = 3, 0, -0.05 do
						wait(0.2)
						m.Volume = i
					end
					m:Destroy()
				end)
				DecreaseVolume()
				for i = 1, #lightbois do
					if lightbois[i]:IsA("Part") then
						lightbois[i].LightObj.Enabled = true
					end
				end
				EaIC.HallwayCutsceneBrick:Destroy()
				EaIC.HallwaySmile.Transparency = 1
			end
		end)
	end
end)

EaIC.EnterChapter2.Touched:Connect(function(part)
	local player = game.Players:GetPlayerFromCharacter(part.Parent)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		BadgeServ:AwardBadge(player.UserId,2124476488)
		RepStorage.StartChapter:FireClient(player,2)
	end
end)

EaIC.ChangingRooms.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and EaIC.OnesToShow.Part.Transparency == 1 then
		local myparts = EaIC.OnesToShow:GetChildren()
		for i = 1, #myparts do
			myparts[i].Transparency = 0
			myparts[i].CanCollide = true
			if myparts[i]:FindFirstChild("Texture") then
				myparts[i].Texture.Transparency = 0
			end
		end
		local myparts = EaIC.OnesToHide:GetChildren()
		for i = 1, #myparts do
			myparts[i].Transparency = 1
			myparts[i].CanCollide = false
			if myparts[i]:FindFirstChild("Texture") then
				myparts[i].Texture.Transparency = 1
			end
		end
	end
end)

EaI.CutsceneParts.DoorBlockRemove.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		if EaI.CutsceneParts:FindFirstChild("DoorBlock") then
			EaI.CutsceneParts:FindFirstChild("DoorBlock"):Destroy()
		end
	end
end)

EaI.CutsceneParts.DoorBlock.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) then
		if EaI.CutsceneParts:FindFirstChild("DoorBlock") then
			RepStorage.Splash:FireClient(game.Players:GetPlayerFromCharacter(part.Parent),"I should stay out of the dark rooms.")
		end
	end
end)

RepStorage.Lights.OnServerEvent:Connect(function(Player,Item)
	if Item.Current_State.Value == false then
		Item.Current_State.Value = true
		Item.On.Transparency = 0
		Item.Base.Switch:Play()
		Item.Off.Transparency = 1
		local ToSelectFrom = Item.LightGroup.Value:GetChildren()
		local Lights = {}
		for i = 1, #ToSelectFrom do
			if ToSelectFrom[i]:IsA("Model") then
				ToSelectFrom[i]:Destroy()
			else
				table.insert(Lights,1,ToSelectFrom[i])
			end
		end
		if Item.SpecialInstructions.Value == 1 then
			CutScene1(Player)
		elseif Item.SpecialInstructions.Value == 2 then
			local we = coroutine.wrap(function()
				local c = script.Ost1:Clone()
				c.Parent = workspace
				c:Play()
				for i = 0, 1.5, 0.025 do
					wait(0.035)
					c.Volume = i
				end
				c.Volume = 2
			end)
			we()
		end
		for i = 1, #Lights do
			local RunLightChange = coroutine.wrap(function(obj)
				local LightObj = obj:FindFirstChild("LightObj")
				if LightObj ~= nil then
					local brightness = LightObj.Brightness
					for sk = brightness/10, brightness, brightness/10 do
						LightObj.Enabled = true
						LightObj.Brightness = sk
						wait(.12)
					end
					
					LightObj.Brightness = brightness
				end
			end)
			RunLightChange(Lights[i])
		end
	end
end)

EaIC.PipeTrigger1.Touched:Connect(function(p)
	
	HandleSteamEvent(p,"Second")
end)
EaIC.PipeTrigger2.Touched:Connect(function(p)
	
	HandleSteamEvent(p,"First")
end)
local ChillKiddies = EaI.CameraChanges:GetChildren()
for i = 1, #ChillKiddies do
	CameraTouchEvents(ChillKiddies[i])
end



EaIC.VoidKill.Touched:Connect(function(p)
	local p = p.Parent
	if game.Players:GetPlayerFromCharacter(p) then
		HandleDeath(game.Players:GetPlayerFromCharacter(p),"Void")
	end
end)

RepStorage.Death.OnServerEvent:Connect(function(plr,Chp)
	plr.Character.Humanoid.WalkSpeed = 14
	plr.Character.Humanoid.JumpPower = 35
	script.ResetHideSeeks:Fire()
	LockedSteam = false
	script.ResetPhones:Fire()
	Ch3MusicPlayed = false
	PitDebounce = false
	EaIC.NoGoingBack.CanCollide = false
	local m = script.SpookyPart.Value.Inner:GetChildren()
	for i = 1, #m do
		if m[i].BrickColor == BrickColor.new("Dirt brown") then
			m[i].Transparency = .5
			m[i].Anchored = false
		else
			m[i].Transparency = 0
			m[i].Anchored = false
		end
		m[i].Parent.Union.CanCollide = true
	end
	if ElevatorNumber ~= 17 then
		ElevatorNumber = 5
	end
	EaIC.Ele2.Door2.Position = Vector3.new(-447.756, 3.77, -324.379)
	EaIC.Ele2.Door1.Position = Vector3.new(-444.256, 3.77, -324.379)
	EaIC.PitEyes.Position = Vector3.new(-515.95, -16.15, -423.767)
	for _,v in pairs(EaI.ClonesToRemove:GetChildren()) do v:Destroy() end
	EaIC.MovingBookShelf.IKnowText1.Decal.Transparency = 1
	EaIC.MovingBookShelf.IKnowText2.Decal.Transparency = 1
	CorneredAlready = false
	ReadyToBeCornered = false
	FallSceneActivated		 =		 false
	FallScenePlayerSafe		 =		false
	FallSceneTimeCount		 =		 13
	script.FixFallScene:Fire()
	wait(3)
	EaIC.MovingBookShelf.BuildingPart:SetPrimaryPartCFrame(EaIC.MovingBookShelf.Marker.CFrame)
	
end)

RepStorage.StartChapter.OnServerEvent:Connect(function(plr,chp)
	if plr.Character then
		HasGameStarted = true
		if chp == 1 then
			--I guess stuff for chapter 1 here
		elseif chp == 2 then
			wait(1.75)
			plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.BlockToWalkTo.Position,EaIC.BlockToWalkTo)
			wait(1.5)
			plr.Character.Humanoid.AutoRotate = false
			local gyroclone = Instance.new("BodyGyro")
			gyroclone.Parent = plr.Character.HumanoidRootPart
			gyroclone.P = 6000
			gyroclone.MaxTorque = Vector3.new(40000000,50000,40000000)
			gyroclone.CFrame = EaIC.HoleTeleport.CFrame
			local m = script.bookshelf:Clone()
			m.Parent = EaIC.HoleTeleport
			m.Volume = 1.5
			m:Play()
			local waititout = coroutine.wrap(function(m)
				wait(6.2)
				m:Destroy()
			end)
			waititout(m)			
			wait(2.5)
			EaIC.NoGoingBack.CanCollide = true
			RepStorage.Splash:FireClient(plr,"Looks like I'm stuck, better watch my step.")
			gyroclone:Destroy()
			plr.Character.HumanoidRootPart.CFrame = EaIC.BlockToWalkTo.CFrame
			plr.Character.Humanoid.AutoRotate = true
			wait(1)
			plr.Character.Humanoid.WalkSpeed = 14
			plr.Character.Humanoid.JumpPower = 35
			repeat
				plr.Character.Humanoid.AutoRotate = true
				wait(1)
			until plr.Character.Humanoid.AutoRotate == false
		elseif chp == 3 then
			Chap3Thing(plr.Character.HumanoidRootPart)
		elseif chp == 4 then
			Chap4Thing(plr.Character:WaitForChild("HumanoidRootPart"))
			EaIC.NoGoingBack2.CanCollide = false
			wait(1)
			plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.Ch4WalkPart1.Position,EaIC.Ch4WalkPart1)
			wait(2)
			plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.Ch4WalkPart2.Position,EaIC.Ch4WalkPart2)
			wait(2)
			plr.Character:WaitForChild("HumanoidRootPart").CFrame = EaIC.Ch4WalkPart2.CFrame
			EaIC.NoGoingBack2.CanCollide = true
		elseif chp == 5 then
			Chap5Thing(plr.Character.HumanoidRootPart)
			wait(1)
			plr.Character:WaitForChild("Humanoid"):MoveTo(EaIC.Ch5Walkpart.Position,EaIC.Ch5Walkpart)
			wait(3)
			plr.Character.HumanoidRootPart.CFrame = EaIC.Ch5Walkpart.CFrame
			EaIC.Ch5BlockPart.CanCollide = true
		end
	end
end)

RepStorage.SkipPhone.OnServerEvent:Connect(function(plr)
	PhoneSkipped = true
end)

EaIC.NoGoingBack.Touched:Connect(function(part)
	if game.Players:GetPlayerFromCharacter(part.Parent) and EaIC.NoGoingBack.CanCollide == true then
		game.ReplicatedStorage.Splash:FireClient(game.Players:GetPlayerFromCharacter(part.Parent),"No reason to go back")
	end
end)
--[[  Boot  ]]--
game:GetService("ServerStorage").DevArchives.Sky.Parent = Lighting
Lighting.Ambient = Color3.fromRGB(0,0,0)
LightFlickerLop()
for i = 1, #ParentsOfInvisibles do
	local SecondaryChild = ParentsOfInvisibles[i]:GetChildren()
	for m = 1, #SecondaryChild do
		if SecondaryChild[m]:IsA("Part") then
			SecondaryChild[m].Transparency = 1
		end
	end
end
Menu_CFVal.Value = workspace.Cameras.CamModel.CamBas.CFrame
StartCameraLoop()
for i = 1, #Doors do
	if Doors[i].CustomLock.Value == true or Doors[i].Unopenable.Value == true then
		Doors[i].Inner.Union.Anchored = true
	end
	DoorEvents(Doors[i])
end

for i = 1, #Lockers do
	LockerEvents(Lockers[i])
end

for i = 1, #Keys do
	KeyEvents(Keys[i])
end

for i = 1, #Texts do
	TextEvents(Texts[i])
end

for i = 1, #Notes do
	NoteEvents(Notes[i])
end

for i = 1, #AudioStops do
	StartAEvents(AudioStops[i])
end

for i = 1, #AudioStarts do
	StopAEvents(AudioStarts[i])
end
for i = 1, #BarBlocks do
	BarEvents(BarBlocks[i])
end
for i = 1, #HideBlocks do
	manageHide(HideBlocks[i])
end
for i = 1, #AmbientBlocks do
	AmbientEvents(AmbientBlocks[i])
end
for i = 1, #PhoneBlocks do
	PhoneEvents(PhoneBlocks[i])
end
for i = 1, #MetalDoors do
	MetalDoorEvents(MetalDoors[i])
end
PhysicsService:CreateCollisionGroup("Barriers")
PhysicsService:CreateCollisionGroup("Boxes")
for i = 1, #PushingBoxes do
	PhysicsService:SetPartCollisionGroup(PushingBoxes[i].PushBox, "Boxes")
	local c = PushingBoxes[i].Hitboxes:GetChildren()
	for m = 1, #c do
		PhysicsService:SetPartCollisionGroup(c[m], "Barriers")
	end
end
PhysicsService:CollisionGroupSetCollidable("Barriers", "Default", false)
PhysicsService:CollisionGroupSetCollidable("Barriers", "Boxes", true)


local textBox = EaIC.Monitor1.Part.SurfaceGui.TextBox

textBox.InputBegan:connect(function(inputObject)
	if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
		textBox:CaptureFocus()
	end
end)

ScriptContext.Error:Connect(function(msg,trace,theonethatdidit)
	if theonethatdidit == script then
		RepStorage.TriggerAnError:FireAllClients(msg,trace)
	end
end)

RandomLightFlicker()
EyeLoops()
TheFallScene()

Sorry that you think that this is alot. But it has the Whole Code in it, Can anybody help me find the part where i can change the camera setting to first person?

You generally should not be editing the client’s camera on the server. Instead, set up a client script where you set the camera’s Enum.CameraType to Enum.CameraType.Scriptable, allowing you to edit how the camera behaves.

This will allow you to switch your camera system to first person, for that I recommend you to take a quick look on google if you need help, as the question has been answered previously.

I found that part already in ServerMainScript and it’s already scriptable

The camera is a model, I tried removing it and the parts too…I doesn’t work, It just damage the whole game.