---------------------------------------------------------------------------------------------------- -- // Services \\ -- local PlayersService = game:GetService("Players") local CollectionService = game:GetService("CollectionService") -- // Constants \\ -- local DOORS = CollectionService:GetTagged("PrimaryDoor") local DoorModule = require(script.Parent.Parent.Libraries.DoorModule) local Permissions = require(script.Parent.Parent.Libraries.Permissions) ---------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- game.ReplicatedStorage.RemoteEvent.DoorSystem.OnServerEvent:Connect(function(player, doorModel, scannerModel) if not doorModel or not scannerModel then return false end if DoorModule.hasCooldown(doorModel) then return false end if not CollectionService:HasTag(doorModel, "PrimaryDoor") then return false end if doorModel:FindFirstChild("Configuration") == nil then return false end if doorModel.Configuration.DoorType.Value ~= script.Name then return false end if script.Parent.Parent.Libraries.Permissions:FindFirstChild(doorModel.Configuration.Permissions.Value) == nil then return false end -- if not DoorModule.canSeeDoor(doorModel, player.Character) then return false end local DoorConfiguration = DoorModule.returnDoorConfiguration(doorModel.Configuration.DoorType.Value) local DoorPermissions = Permissions.returnPermission(doorModel.Configuration.Permissions.Value) if not DoorPermissions then return warn("[DoorSystem] Unknown Door Permission.") end if not DoorPermissions.hasPermission(player) then scannerModel.PrimaryPart.Keycard_Denied:Play() scannerModel.PrimaryPart.Color = Color3.fromRGB(255, 0, 0) delay(2, function() if doorModel.Configuration.Lockdown.Value then scannerModel.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) else scannerModel.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end end) DoorModule.setCooldown(doorModel, DoorConfiguration["Cooldown"]) return false else scannerModel.PrimaryPart.Keycard_Accepted:Play() scannerModel.PrimaryPart.Color = Color3.fromRGB(0, 255, 0) delay(2, function() if doorModel.Configuration.Lockdown.Value then scannerModel.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) else scannerModel.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end end) end doorModel.Configuration.Open.Value = not doorModel.Configuration.Open.Value DoorModule.setCooldown(doorModel, DoorConfiguration["Cooldown"]) end) ---------------------------------------------------------------------------------------------------- for _, Door in pairs(DOORS) do if not CollectionService:HasTag(Door, "PrimaryDoor") then return false end if Door:FindFirstChild("Configuration") == nil then return false end if Door.Configuration.DoorType.Value ~= script.Name then return false end if script.Parent.Parent.Libraries.Permissions:FindFirstChild(Door.Configuration.Permissions.Value) == nil then return false end local DoorConfiguration = DoorModule.returnDoorConfiguration(Door.Configuration.DoorType.Value) Door.Configuration.Open:GetPropertyChangedSignal("Value"):Connect(function() if Door.Configuration.Open.Value then Door.Door0.PrismaticConstraint.Speed = DoorConfiguration["OpenSpeed"] Door.Door0.PrismaticConstraint.TargetPosition = DoorConfiguration["OpenTarget"] Door.Door1.PrismaticConstraint.Speed = DoorConfiguration["OpenSpeed"] Door.Door1.PrismaticConstraint.TargetPosition = DoorConfiguration["OpenTarget"] Door.Door0.Door_Open:Play() Door.Door0.Door_Close:Stop() else Door.Door0.PrismaticConstraint.Speed = DoorConfiguration["CloseSpeed"] Door.Door0.PrismaticConstraint.TargetPosition = DoorConfiguration["CloseTarget"] Door.Door1.PrismaticConstraint.Speed = DoorConfiguration["CloseSpeed"] Door.Door1.PrismaticConstraint.TargetPosition = DoorConfiguration["CloseTarget"] Door.Door0.Door_Open:Stop() Door.Door0.Door_Close:Play() end end) Door.Configuration.Lockdown:GetPropertyChangedSignal("Value"):Connect(function() if Door.Configuration.Lockdown.Value then for _, Scanner in pairs(Door:GetChildren()) do if CollectionService:HasTag(Scanner, "InteractionSystem") then Scanner.PrimaryPart.Color = Color3.fromRGB(218, 133, 65) end end else for _, Scanner in pairs(Door:GetChildren()) do if CollectionService:HasTag(Scanner, "InteractionSystem") then Scanner.PrimaryPart.Color = Color3.fromRGB(13, 105, 172) end end end end) end