Hey! I made this door module for my game, it’s not complete but you can see where it’s going. It’s meant to change the cframe of a door if the user that clicked the door is allowed.
Code:
local module = {}
--Services--
local Players = game:GetService("Players")
local WS = game:GetService("Workspace")
--Locals--
local Group = 5707891
local MinRank = 251
local DoorFolder = WS.Doors
local MD1 = DoorFolder.MainDoor1
local MDA = DoorFolder.MainDoorA
--Local Functions --
local function IsAllowed(plr)
if plr:GetRoleInGroup(Group) >= MinRank then
return "Allowed"
elseif plr:FindFirstChild("Val").Value == "Host"then
return "Allowed"
elseif plr:FindFirstChild("Val").Value == "Co-Host"then
return "Allowed"
elseif plr:FindFirstChild("Val").Value == "Interviewer"then
return "Allowed"
else
end
end
local function DoorOpen(Door)
if Door.Name == "MainDoor1" or Door.Name == "MainDoorA"then
MD1.Union.Position = CFrame.new(-12.038, 4.014, 9.458)
MD1.Panel.Position = CFrame.new(-12.065, 4.032, 9.472)
MD1.OpenDoorButton.Position = CFrame.new(-10.766, 3.934, 9.477)
MDA.Union.Position = CFrame.new(-12.028, 4.011, 18.051)
MDA.OpenDoorButton.Position = CFrame.new(-10.756, 3.929, 18.07)
MDA.Panel.Position = CFrame.new(-12.055, 4.007, 18.065)
elseif Door.Name == "IntOffice1" then
Door.Union.Position = CFrame.new(-7.36, 4.011, 4.084)
Door.OpenDoorButton.Position = CFrame.new(-7.341, 3.929, 2.812)
Door.Panel.Position = CFrame.new()
elseif Door.Name == "IntOffice2" then
elseif Door.Name == "IntOffice3" then
elseif Door.Name == "IntOffice4" then
elseif Door.Name == "IntOffice5" then
elseif Door.Name == "IntOffice5" then
elseif Door.Name == "IntOffice6" then
elseif Door.Name == "IntOffice7" then
elseif Door.Name == "IntOffice8" then
else
warn("Invalid request: "..Door.Name.."Is not a door!")
end
end
local function DoorClose(Door)
if Door.Name == "MainDoor1" then
elseif Door.Name == "MainDoorA" then
elseif Door.Name == "IntOffice1" then
elseif Door.Name == "IntOffice2" then
elseif Door.Name == "IntOffice3" then
elseif Door.Name == "IntOffice4" then
elseif Door.Name == "IntOffice5" then
elseif Door.Name == "IntOffice5" then
elseif Door.Name == "IntOffice6" then
elseif Door.Name == "IntOffice7" then
elseif Door.Name == "IntOffice8" then
else
warn("Invalid request: "..Door.Name.."Is not a door!")
end
end
local function ChangeBool(Bool)
if Bool.Value == true then
Bool.Value = false
elseif Bool.Value == false then
Bool.Value = true
else
warn("Invalid request: "..Bool.Name.."Is not a Bool Value.")
end
end
--Big Function --
function module.Door(Bool,door,plr)
local returned = IsAllowed(plr)
if returned == "Allowed" then
if Bool == true then
DoorClose(door)
ChangeBool(Bool)
elseif Bool == false then
DoorOpen(door)
ChangeBool(Bool)
else
warn("Invalid Request: "..Bool.Name.."Is not a bool value.")
end
end
end
return module