Roblox "CollisionGroups" are getting set back to default upon running the game (In Studio)

I have the world’s simplest few lines of code, stored in an active server script in server script service. It goes as follows:

local PhysicsService = game:GetService("PhysicsService")

PhysicsService:RegisterCollisionGroup("Characters")

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

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		for _, Descendant in ipairs(Character:GetDescendants()) do
			if Descendant:IsA("BasePart") then
				Descendant.CollisionGroup = "Characters"
			end
		end
	end)
end)

I have ran a million tests, and I can confirm that this script successfully makes the collision group “Characters” and sets collisions between them to be false. Furthermore, it is confirmed that this script gets ran on every base part in a player’s character. However, upon inspection in the editor after setting the collision group, it instantly reverts back to the “Default” collision group, which makes it so that players can collide with each other which is undesirable. I don’t understand what I am doing wrong and I feel like this is just something that is not explained by Roblox documentation entirely as how can something this simple keep persistently messing up. I should also add that I have checked every script and in not any of the scripts is the collision group being set. What can I do? Any help is appreciated.

idk how to help, but why you use Character:GetDescendants() ? It getting character parents, not the childrens

That is “ancestors” not “descendants”.

mmm, my bad then.
i often use :GetChildrens()

I just used task.wait(1) before setting the collision group and that apparently counts as a “fix”. Whatever that means.

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