Collisions Groups not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to Disable both Player and Player Collisions and Player and NPC Collisions.
  2. What is the issue? Include screenshots / videos if possible!
    For some reason you can still collide with the NPC.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried Debugging the script with print statements, and the bodyparts are getting put to their respective Collision Groups. I know they work since when I disable the Collisions with Default, they fall through.

Screenshot_419

--Script inside of ServerScriptService
local Players = game:GetService("Players")
local BubblxNPC = game.Workspace["BubblxYT NPC"]

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i, bodypart in pairs(char:GetDescendants()) do
			if bodypart:IsA("BasePart") then
				bodypart.CollisionGroup = "Players"
				print("Bodypart: " .. bodypart.Name .. " has been added to the collisiongroup " .. bodypart.CollisionGroup)
			end
		end
	end)
end)

for i, bodypart in pairs(BubblxNPC:GetDescendants()) do
	if bodypart:IsA("BasePart") then
		bodypart.CollisionGroup = "NPCS"
		print("Bodypart: " .. bodypart.Name .. " has been added to the collisiongroup " .. bodypart.CollisionGroup)
	end
end

Any Help would be nice!

It’s because you didn’t add collisions to any new parts that may be added to your character. You need to wait until your entire character has been loaded before you add collision groups.

Code:

--//Services
local Players = game:GetService("Players")

--//Variables
local BubblxNPC = workspace["BubblxYT NPC"]

--//Functions
Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		for i, descendant in ipairs(character:GetDescendants()) do
			if descendant:IsA("BasePart") then
				descendant.CollisionGroup = "Players"
				print("Bodypart: " .. descendant.Name .. " has been added to the collisiongroup " .. descendant.CollisionGroup)
			end
		end
	end)
end)

for i, descendant in ipairs(BubblxNPC:GetDescendants()) do
	if descendant:IsA("BasePart") then
		descendant.CollisionGroup = "NPCS"
		print("Bodypart: " .. descendant.Name .. " has been added to the collisiongroup " .. descendant.CollisionGroup)
	end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.