I have made an SCP game and I have a problem with a toggle button script this script used to work but is now broken for some reason and I am not sure if it has been broken or if roblox has changed the way scripts work and that script is no longer compatible. The script is supposed to get the rank of a player attempting to press the toggle and if their rank is above a certain rank it works if they are not it doesn't then all the doors in a certain room close.

Script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local PlayerService = game:GetService('Players')
local Workspace = game:GetService('Workspace')
local TweenService = game:GetService('TweenService')

local DOOR_ROOT = Workspace:WaitForChild('Systems'):WaitForChild('Celldoors'):WaitForChild('Doors')

local NetworkEvents = ReplicatedStorage:WaitForChild("NewEvents")
local DoorRemote = NetworkEvents:WaitForChild('DoorReplicate')

local Permissions = {}

function HasPermissionToUse(Player)
	if Permissions[Player] == nil then
		Permissions[Player] = Player:GetRankInGroup(2874380) >= 200 or Player:GetRankInGroup(3857842) >= 20 or Player:IsInGroup(3857842) or Player:IsInGroup(3857860)
	end
	return Permissions[Player]
end

DoorRemote.OnServerEvent:Connect(function(Player, Type, Door, Switch)
	if not HasPermissionToUse(Player) then return end
	
	if Type == "ToggleDoor" then
		if Door and DOOR_ROOT:FindFirstChild(Door) then
			DOOR_ROOT:FindFirstChild(Door).Status.Value = Switch and Switch or false
			DOOR_ROOT:FindFirstChild(Door).Barrier.CanCollide = not DOOR_ROOT:FindFirstChild(Door).Status.Value
		end
	elseif Type == "ToggleAll" then
		DOOR_ROOT.Parent.AllStatus.Value = not DOOR_ROOT.Parent.AllStatus.Value
		for _,DoorModel in pairs(DOOR_ROOT:GetChildren()) do
			DoorModel.Status.Value = DOOR_ROOT.Parent.AllStatus.Value
			DoorModel.Barrier.CanCollide = not DoorModel.Status.Value
		end
	elseif Type == "ToggleRiot" then
		DOOR_ROOT.Parent.RiotAlarm.Value = not DOOR_ROOT.Parent.RiotAlarm.Value
		if DOOR_ROOT.Parent.RiotAlarm.Value then
			--Master Event Announcement
		end
	end
end)