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