local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local OfficeObjs = workspace.OfficeObjs
local Office = {
WestDoor = OfficeObjs.WestDoor,
EastDoor = OfficeObjs.EastDoor,
WestLight = OfficeObjs.WestLight,
EastLight = OfficeObjs.EastLight,
WestDBtn = OfficeObjs.WestDoorSwitch.Button,
EastDBtn = OfficeObjs.EastDoorSwitch.Button,
WestLBtn = OfficeObjs.WestLightSwitch.Button,
EastLBtn = OfficeObjs.EastLightSwitch.Button
}
local active = false
local debounce = false
local function Create(instance, name, parent, value, color)
local new = Instance.new(instance)
new.Name = name
new.Parent = parent
return new
end
WestDBtn.Click.MouseDown:Conenct(function()
if not active and not debounce then
WestDBtn.Color3 = Color3.fromRGB(0, 255, 0) -- green
local info = TweenInfo.new(
0.2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {
Position = Vector3.new(Office.WestDoor.Position.X, 6.5, Office.WestDoor.Position.Z)
}
local opent = TweenService:Create(Office.WestDoor, info, goal)
opent:Play()
Sounds.Objects.DoorSlam:Play()
active = true
debounce = true
wait(3)
debounce = false
elseif active then
WestDBtn.Color3 = Color3.fromRGB(255, 0, 0) -- red
local info = TweenInfo.new(
1.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {
Position = Vector3.new(Office.WestDoor.Position.X, 15.5, Office.WestDoor.Position.Z)
}
local closet = TweenService:Create(Office.WestDoor, info, goal)
closet:Play()
Sounds.Objects.DoorOpen:Play()
active = false
debounce = true
wait(3)
debounce = false
end
if debounce then return end
end)
EastDBtn.Click.MouseDown:Conenct(function()
if not active and not debounce then
EastDBtn.Color3 = Color3.fromRGB(0, 255, 0) -- green
local info = TweenInfo.new(
0.2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {
Position = Vector3.new(Office.EastDoor.Position.X, 6.5, Office.EastDoor.Position.Z)
}
local opent = TweenService:Create(Office.EastDoor, info, goal)
opent:Play()
Sounds.Objects.DoorSlam:Play()
active = true
debounce = true
wait(3)
debounce = false
elseif active then
EastDBtn.Color3 = Color3.fromRGB(255, 0, 0) -- red
local info = TweenInfo.new(
1.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {
Position = Vector3.new(Office.EastDoor.Position.X, 15.5, Office.EastDoor.Position.Z)
}
local closet = TweenService:Create(Office.EastDoor, info, goal)
closet:Play()
Sounds.Objects.DoorOpen:Play()
active = false
debounce = true
wait(3)
debounce = false
end
if debounce then return end
end)
WestLBtn.Click.MouseDown:Connect(function()
if not active and not debounce then
WestLBtn.Color3 = Color3.fromRGB(0, 255, 0) -- green
local LightSource = Create("SurfaceLight", "WestLightSource", OfficeObjs.wl_Source)
-- custom light stuff here
active = true
debounce = true
wait(1)
debounce = false
elseif active then
WestLBtn.Color3 = Color3.fromRGB(255, 255, 255) -- white
for i,v in pairs(OfficeObjs.wl_Source:GetChildren()) do
if v:IsA("SurfaceLight") and v.Name == "WestLightSource" then
if i >= 2 then
warn("More than one instance found [" .. i .. " items]")
end
v:Destroy()
print(v .. " successfully removed [item#" .. i)
else
warn("Error, could not find " .. v .. " [" .. v.ClassName .. "]")
return
end
end
active = false
debounce = true
wait(1)
debounce = false
end
if debounce then return end
end)
EastLBtn.Click.MouseDown:Connect(function()
if not active and not debounce then
EastLBtn.Color3 = Color3.fromRGB(0, 255, 0) -- green
local LightSource = Create("SurfaceLight", "EastLightSource", OfficeObjs.el_Source)
-- custom light stuff here
active = true
debounce = true
wait(1)
debounce = false
elseif active then
EastLBtn.Color3 = Color3.fromRGB(255, 255, 255) -- white
for i,v in pairs(OfficeObjs.el_Source:GetChildren()) do
if v:IsA("SurfaceLight") and v.Name == "EastLightSource" then
if i >= 2 then
warn("More than one instance found [" .. i .. " items]")
end
v:Destroy()
print(v .. " successfully removed [item#" .. i)
else
warn("Error, could not find " .. v .. " [" .. v.ClassName .. "]")
return
end
end
active = false
debounce = true
wait(1)
debounce = false
end
if debounce then return end
end)
To embed this project on your website, copy the following code and paste it into your website's HTML: