How to lock certain door groups? [DarkRP]

So I have the PD doors set to the Cops and Mayor only door group, I am trying to get these to lock on server start. Can anyone help me with this? So far I have something to get all the doors (code below) but how do I get the door group of it?

PS: I dont know which one I will use yet they are pretty much the same

--for k, v in pairs( ents.GetAll() ) do
--	local class = v:GetClass()
--	if class == "prop_door_rotating" then
--	end

--for _, ent in ipairs(ents.GetAll()) do
--	if ent:IsDoor() == true then
--	end

To lock the doors you have to use

Entity:Fire with the “lock” argument.
Now, to filter only doors from a specific group you’ve gotta check if those doors are from that group, which should be able to be achieved by using Entity:getKeysDoorGroup or Entity:getKeysDoorTeams
And also instead of checking if the class is “prop_door_rotating” you should use the native DarkRP function Entity:isDoor

[editline]28th July 2017[/editline]

Next time take a look at and

[editline]28th July 2017[/editline]

Also, you should call all of this on the hook

GM:Initialize so you make sure that DarkRP has loaded when you run it.

Thank you this helped me so much, but I was putting the code in the darkrp modification folder so GM:Initialize wasnt being called. So I created a timer and found where the entities were created and added a couple seconds to it. Thank you.