How to assign Player A Collision Group

I need help assigning all player who join a collision group. I don’t know here to start and I have watched multiple tutorials.

1 Like

See this example Script supplied by create.roblox.com/docs which adds all the parts of a player’s character to the “Characters” CollisionGroup in order to disable player collisions.

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")

PhysicsService:RegisterCollisionGroup("Characters")
PhysicsService:CollisionGroupSetCollidable("Characters", "Characters", false)

local function onDescendantAdded(descendant)
	-- Set collision group for any part descendant
	if descendant:IsA("BasePart") then
		descendant.CollisionGroup = "Characters"
	end
end

local function onCharacterAdded(character)
	-- Process existing and new descendants for physics setup
	for _, descendant in pairs(character:GetDescendants()) do
		onDescendantAdded(descendant)
	end
	character.DescendantAdded:Connect(onDescendantAdded)
end

Players.PlayerAdded:Connect(function(player)
	-- Detect when the player's character is added
	player.CharacterAdded:Connect(onCharacterAdded)
end)
16 Likes

Thank you so much for the solution

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