I’m trying to allow players to walk through pets following them that have humanoids, but no matter what, they can’t walk through the humanoids. Here’s my code currently:
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("HumanoidPets")
function playerAdded(player)
local character = player.Character or player.CharacterAdded:Wait();
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "Players";
end
end
end
for _, pet in pairs(game.ReplicatedStorage.PetModels:GetChildren()) do
if pet:FindFirstChildWhichIsA("Humanoid") then
for _, part in pairs(pet:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "HumanoidPets"
end
end
end
end
game.Players.PlayerAdded:Connect(playerAdded);
for _, player in pairs(game.Players:GetPlayers()) do
playerAdded(player);
end
PhysicsService:CollisionGroupSetCollidable("Players", "HumanoidPets", false)
PhysicsService:CollisionGroupSetCollidable("HumanoidPets", "HumanoidPets", false)
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)