Physics Service Error

I am trying to set collision off in my game for both player and npcs. Player works just fine, but NPCs dont work. You can see in my script I had tried debugging using some prints statements. Here is the script.

Script

--// Services
local SSS = game:GetService('ServerScriptService')
local PhysicsService = game:GetService('PhysicsService')
local Players = game:GetService('Players')

--// Variables [Player Collision]
local PlayerGroup = PhysicsService:CreateCollisionGroup('PlayerCollide')
PhysicsService:CollisionGroupSetCollidable('PlayerCollide', 'PlayerCollide', false)

--// Variables [NPC Collisions]
local NPCGroup = PhysicsService:CreateCollisionGroup('NPCCollide')
PhysicsService:CollisionGroupSetCollidable('NPCCollide', 'NPCCollide', false)
PhysicsService:CollisionGroupSetCollidable('NPCCollide', 'PlayerCollide', false)


function NoCollidePlayer(model)
	for _, parts in pairs(model:GetChildren()) do
		if parts:IsA('BasePart') then
			print("[Server] - Physics Service Loaded! Collision Group.. Player!")
			PhysicsService:SetPartCollisionGroup(parts, 'PlayerCollide')
		end
	end
end

function playerAdded(player)
	player.CharacterAdded:Connect(function(char)
		char:WaitForChild('HumanoidRootPart')
		char:WaitForChild('Head')
		char:WaitForChild('Humanoid')	
		wait(0.1)
		if char then
			NoCollidePlayer(char)
		end
	end)
end

Players.PlayerAdded:Connect(playerAdded)

for _, parts in pairs(workspace.NPCs:GetDescendants()) do
	if parts and parts:FindFirstChildWhichIsA('Humanoid') then
		print('Part!')
		if parts:IsA('BasePart') or parts:IsA('MeshPart') then
			print("[Server] - Physics Service Loaded! Collision Group.. NPC!")
			PhysicsService:SetPartCollisionGroup(parts, 'NPCCollide')
		end	
		wait()
	end			
end
wait(.1)

Just realized I didnt need to call the ServerScriptService as I have never used it.

Came back to tell that this problem hasn’t been solved yet. :))

Problem has been resolved for those wondering about Physic with the NPC, all I had to do was replace line 42 – 44 because I was checking for baseparts right after looking for a model, which was there. Here is the code fixed code if anyone ever comes by later!

--// Services
local SSS = game:GetService('ServerScriptService')
local PhysicsService = game:GetService('PhysicsService')
local Players = game:GetService('Players')

--// Variables [Player Collision]
local PlayerGroup = PhysicsService:CreateCollisionGroup('PlayerCollide')
PhysicsService:CollisionGroupSetCollidable('PlayerCollide', 'PlayerCollide', false)

--// Variables [NPC Collisions]
local NPCGroup = PhysicsService:CreateCollisionGroup('NPCCollide')
PhysicsService:CollisionGroupSetCollidable('NPCCollide', 'NPCCollide', false)
PhysicsService:CollisionGroupSetCollidable('NPCCollide', 'PlayerCollide', false)


function NoCollidePlayer(model)
	for _, parts in pairs(model:GetChildren()) do
		if parts:IsA('BasePart') then
			print("[Server] - Physics Service Loaded! Collision Group.. Player!")
			PhysicsService:SetPartCollisionGroup(parts, 'PlayerCollide')
		end
	end
end

function playerAdded(player)
	player.CharacterAdded:Connect(function(char)
		char:WaitForChild('HumanoidRootPart')
		char:WaitForChild('Head')
		char:WaitForChild('Humanoid')	
		wait(0.1)
		if char then
			NoCollidePlayer(char)
		end
	end)
end

Players.PlayerAdded:Connect(playerAdded)

for _, parts in pairs(workspace.NPCs:GetDescendants()) do
	if parts:IsA('BasePart') or parts:IsA('MeshPart') then
		print("[Server] - Physics Service Loaded! Collision Group.. NPC!")
		PhysicsService:SetPartCollisionGroup(parts, 'NPCCollide')
	end			
end
wait(.1)