Collision Group problem

I’m currently trying to make it so that players walk through the Ais. I was also able to make it so the Ai can walk through each other, which works. For some reason, I’m having difficulty with the Player to Ai. I feel like there is a really easy way of doing this.

script.Parent = game:GetService("ServerScriptService")
local PhysService = game:GetService("PhysicsService")
local PlayerGroup = PhysService:CreateCollisionGroup("g")
local AiBaseA = PhysService:CreateCollisionGroup("a")

function NoCollideAi(plychar)
	game.Workspace.Bases.BaseA.NewPassangers.ChildAdded:Connect(function(aichar)
		for i,v in pairs(aichar:GetChildren()) do
			if v:IsA("BasePart") then
				PhysService:SetPartCollisionGroup(v, "a")
				for e,c in pairs(plychar:GetChildren()) do 
					if c:IsA"BasePart" then
						PhysService:SetPartCollisionGroup(c,"g")
						PhysService:CollisionGroupSetCollidable("g", "a", false)
					end
				end
			end
		end
	end)
end
game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(plychar)
		plychar:WaitForChild("HumanoidRootPart")
		NoCollideAi(plychar)
	end)
end)```

Just figured it out, so It’s all good.

1 Like

You didn’t really ask a question in the OP and didn’t specify a problem either, so it’d be pretty difficult to help you in the first place. On the other hand, mind specifying how you resolved your issue? Others may be looking through this thread having the same problem as you.

Replying with “nevermind I figured it out” doesn’t leave room for others to reference your solution, if it’s able to help them as well. It’s also not really constructive, for which replies should be.