--[[
    Services
--]]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

--[[
    Rep Folders
--]]
local Modules = ReplicatedStorage:WaitForChild("Modules") -- Folder under ReplicatedStorage
local GameFunctionsFolder = ReplicatedStorage:WaitForChild("GameFunctionsFolder") -- Folder under ReplicatedStorage
local Events = ReplicatedStorage:WaitForChild("Events") -- Folder under ReplicatedStorage
local Sounds = ReplicatedStorage:WaitForChild("Sounds") -- Folder under ReplicatedStorage

--[[
    SubFolders for the game functions
--]]
-- Power
local Power = GameFunctionsFolder.Power -- Folder under GameFunctionsFolder
local UsingPower = Power.UsingPower -- BoolValue under Power (Folder)
local PowerConsumption = Power.PowerConsumption -- IntValue under Power (Folder)
local LeftoverPower = Power.LeftoverPower -- IntValue under Power (Folder)
-- Office objects
local EastSide = GameFunctionsFolder.EastSide -- Folder under GameFunctionsFolder
local WestSide = GameFunctionsFolder.WestSide -- Folder under GameFunctionsFolder
local EastDoor = EastSide.EastDoor -- BoolValue under EastSide (Folder)
local EastLight = EastSide.EastLight -- BoolValue under EastSide (Folder)
local WestDoor = WestSide.WestDoor -- BoolValue under WestSide (Folder)
local WestLight = WestSide.WestLight -- BoolValue under WestSide (Folder)

--[[
    In-game objects
--]]
-- office
local Office = workspace.Office -- the entire in-game office model woah
local EastDoorObj = Office.EastDoor -- the actual east door model in-game
local WestDoorObj = Office.WestDoor -- the actual west door model in-game
local EastLightObj = Office.EastLightPart -- the part where the east light is parented to
local WestLightObj = Office.WestLightPart -- the part where the west light is parented to


--[[
    Functions
--]]

-- makes stuff (specifically instances)
                         --arguments woah
local function Create(instance, name, parent)
    local new = Instance.new(instance) -- creates an instance through a variable (string)
    new.Name = name -- give it a name (string)
    new.Parent = parent -- give it a parent (obj)
    
    return new -- return the variable
end

UsingPower.Changed:Connect(function(PowerOut) -- UsingPower's value has been changed (true or false)
    if UsingPower.Value then    -- if UsingPower is true then
        if LeftoverPower <=0 then -- if LeftoverPower is less than or equal to 0 then
            PowerOut = true -- argument's assigned value is false
            return -- return the function to end it
        else -- otherwise..????? maybe????
            EastDoor.Changed:Connect(function()
                if EastDoor.Value then -- if the boi is on
                    local goal = {} -- the goal table
                    goal.Position = Vector3.new(5, 5, 5) -- the positon the funny door goes lol (PLACEHOLDER)
                    goal.Sound = Sounds.DoorSlam:Play() -- the sound the door makes
                
                    local Info = TweenInfo.new(5) -- 5 seconds woahh (PLACEHOLDER)
                
                    local tween = TweenService:Create(EastDoorObj, Info, goal) -- create the tween
                    tween:Play() -- play it back
                else -- if it's not on
                    local goal = {} -- table pt. 2
                    goal.Position = Vector3.new(10, 10, 10) -- door open pos (PLACEHOLDER)
                    goal.Sound = Sounds.DoorOpen:Play() -- door opening
                    
                    local Info = TweenInfo.new(5) -- 5 seconds (PLACEHOLDER)
                    
                    local tween = TweenService:Create(EastDoorObj, Info, goal) -- tween it
                    tween:Play() -- play it
                end
            end)
            -- the same as the east door except it's for the west one
            WestDoor.Changed:Connect(function()
                if WestDoor.Value then    
                    local goal = {}
                    goal.Position = Vector3.new(5, 5, 5) -- the positon the funny door goes lol (PLACEHOLDER)
                    goal.Sound = Sounds.DoorSlam:Play() -- the sound the door makes
                
                    local Info = TweenInfo.new(5)
                
                    local tween = TweenService:Create(WestDoorObj, Info, goal)
                    tween:Play()
                else
                    local goal = {}
                    goal.Position = Vector3.new(10, 10, 10) -- door open pos (PLACEHOLDER)
                    goal.Sound = Sounds.DoorOpen:Play() -- door opening
                    
                    local Info = TweenInfo.new(5)
                    
                    local tween = TweenService:Create(WestDoorObj, Info, goal)
                    tween:Play()
                end
            end)
            
            EastLight.Changed:Connect(function() -- light boi
                local New -- unassigned variable pog
                
                if EastLight.Value then -- if light boi is on
                    New = Create("SurfaceLight", "EastLight", EastLightObj) -- variable now has a value (function just makes instances)
                --  var = funct(   instance name,   name,      parent      )
                else -- otherwise
                    if Office:FindFirstChild(New) then -- if the boi is there and the light isn't supposed to be on, D E S T R O Y
                        New:Destroy() -- boom
                        return -- return the boi
                    end -- this is an end 
                    return -- return 
                end
            end)
            -- the same as the one above
            WestLight.Changed:Connect(function()
                local New
                
                if WestLight.Value then
                    New = Create("SurfaceLight", "WestLight", WestLightObj)
                else
                    if Office:FindFirstChild(New) then
                        New:Destroy()
                        return
                    end
                    return
                end
            end)
        end
        return PowerOut -- return the functions argument
    else -- if the bool value's value is false then return it cus we don't need it *lenny face*
        return -- return the function
    end
end)

local function EastDoorFunc()
    local goal = {}
    
    if EastDoor.Value then
        goal.position = Vector3.new(69, 69, 69)
        goal.sound = Sounds.Objects.DoorSlam:Play()
        
        local Info = TweenInfo.new(1)
        
        local tween = TweenService:Create(EastDoorObj, Info, goal)
        
        tween:Play()
    else
        
    end
end

UsingPower:GetPropertyChangedSignal("Value"):Connect(function(PowerOut)
    if UsingPower.Value then
        PowerOut = false
        if LeftoverPower <= 0 then
            PowerOut = true
            return
        end
        
        if PowerConsumption >= 50 then
            
        
        EastDoor:GetPropertyChangedSignal("Value"):Connect(function()
            

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: