LawMixer

Hanler

Jul 28th, 2021
816
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------------------------------------------------------------------------------------
  2. -- // Services \\ --
  3. local PlayersService = game:GetService("Players")
  4. local CollectionService = game:GetService("CollectionService")
  5.  
  6. -- // Constants \\ --
  7. local DOORS = CollectionService:GetTagged("PrimaryDoor")
  8. local DoorModule = require(script.Parent.Parent.Libraries.DoorModule)
  9. local Permissions = require(script.Parent.Parent.Libraries.Permissions)
  10. ----------------------------------------------------------------------------------------------------
  11.  
  12.  
  13. ----------------------------------------------------------------------------------------------------
  14.  
  15. game.ReplicatedStorage.RemoteEvent.DoorSystem.OnServerEvent:Connect(function(player, doorModel, scannerModel)
  16.     if not doorModel or not scannerModel then return false end
  17.     if DoorModule.hasCooldown(doorModel) then return false end
  18.     if not CollectionService:HasTag(doorModel, "PrimaryDoor") then return false end
  19.     if doorModel:FindFirstChild("Configuration") == nil then return false end
  20.     if doorModel.Configuration.DoorType.Value ~= script.Name then return false end
  21.     if script.Parent.Parent.Libraries.Permissions:FindFirstChild(doorModel.Configuration.Permissions.Value) == nil then return false end
  22. --  if not DoorModule.canSeeDoor(doorModel, player.Character) then return false end
  23.    
  24.     local DoorConfiguration = DoorModule.returnDoorConfiguration(doorModel.Configuration.DoorType.Value)
  25.     local DoorPermissions = Permissions.returnPermission(doorModel.Configuration.Permissions.Value)
  26.     if not DoorPermissions then return warn("[DoorSystem] Unknown Door Permission.") end
  27.    
  28.     if not DoorPermissions.hasPermission(player) then
  29.         scannerModel.PrimaryPart.Keycard_Denied:Play()
  30.         scannerModel.PrimaryPart.Color = Color3.fromRGB(255, 0, 0)
  31.         delay(2, function()
  32.             if doorModel.Configuration.Lockdown.Value then scannerModel.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) else scannerModel.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end
  33.         end)
  34.         DoorModule.setCooldown(doorModel, DoorConfiguration["Cooldown"])
  35.         return false
  36.     else
  37.         scannerModel.PrimaryPart.Keycard_Accepted:Play()
  38.         scannerModel.PrimaryPart.Color = Color3.fromRGB(0, 255, 0)
  39.         delay(2, function()
  40.             if doorModel.Configuration.Lockdown.Value then scannerModel.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) else scannerModel.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end
  41.         end)
  42.     end
  43.    
  44.     doorModel.Configuration.Open.Value = not doorModel.Configuration.Open.Value
  45.     DoorModule.setCooldown(doorModel, DoorConfiguration["Cooldown"])
  46. end)
  47.  
  48. ----------------------------------------------------------------------------------------------------
  49. for _, Door in pairs(DOORS) do
  50.     if not CollectionService:HasTag(Door, "PrimaryDoor") then return false end
  51.     if Door:FindFirstChild("Configuration") == nil then return false end
  52.     if Door.Configuration.DoorType.Value ~= script.Name then return false end
  53.     if script.Parent.Parent.Libraries.Permissions:FindFirstChild(Door.Configuration.Permissions.Value) == nil then return false end
  54.    
  55.     local DoorConfiguration = DoorModule.returnDoorConfiguration(Door.Configuration.DoorType.Value)
  56.    
  57.     Door.Configuration.Open:GetPropertyChangedSignal("Value"):Connect(function()
  58.         if Door.Configuration.Open.Value then
  59.             Door.Door0.PrismaticConstraint.Speed = DoorConfiguration["OpenSpeed"]
  60.             Door.Door0.PrismaticConstraint.TargetPosition = DoorConfiguration["OpenTarget"]
  61.             Door.Door1.PrismaticConstraint.Speed = DoorConfiguration["OpenSpeed"]
  62.             Door.Door1.PrismaticConstraint.TargetPosition = DoorConfiguration["OpenTarget"]
  63.            
  64.             Door.Door0.Door_Open:Play() Door.Door0.Door_Close:Stop()
  65.         else
  66.             Door.Door0.PrismaticConstraint.Speed = DoorConfiguration["CloseSpeed"]
  67.             Door.Door0.PrismaticConstraint.TargetPosition = DoorConfiguration["CloseTarget"]
  68.             Door.Door1.PrismaticConstraint.Speed = DoorConfiguration["CloseSpeed"]
  69.             Door.Door1.PrismaticConstraint.TargetPosition = DoorConfiguration["CloseTarget"]
  70.            
  71.             Door.Door0.Door_Open:Stop() Door.Door0.Door_Close:Play()
  72.         end
  73.     end)
  74.    
  75.     Door.Configuration.Lockdown:GetPropertyChangedSignal("Value"):Connect(function()
  76.         if Door.Configuration.Lockdown.Value then
  77.             for _, Scanner in pairs(Door:GetChildren()) do
  78.                 if CollectionService:HasTag(Scanner, "InteractionSystem")  then Scanner.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) end
  79.             end
  80.         else
  81.             for _, Scanner in pairs(Door:GetChildren()) do
  82.                 if CollectionService:HasTag(Scanner, "InteractionSystem") then Scanner.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end
  83.             end
  84.         end
  85.     end)
  86. end
RAW Paste Data