GetRegisteredCollisionGroups not working?

script:


while true do
	wait(1)
	for _, group in ipairs(game:GetService("PhysicsService"):GetRegisteredCollisionGroups()) do
		if group.Name ~= "default" then
			game:GetService("PhysicsService"):CollisionGroupSetCollidable(groupName,group,false)
		end
	end
end


this is groupname btw

local groupName = script.Parent.Plr.Value.. "ball"

please help

Hey there!

You would have to register the collisionGroup by doing

game:GetService("PhysicsService"):RegisterCollisionGroup(groupName)

Also the .Name property should be lowercase when using the returned items from GetRegisteredCollisionGroups:

while true do
	task.wait(1)
	for _, group in game:GetService("PhysicsService"):GetRegisteredCollisionGroups() do
		if group.name ~= "Default" then
			game:GetService("PhysicsService"):CollisionGroupSetCollidable(groupName,group.name,false)
		end
	end
end

i already registered groupname, heres the full script:

local groupName = script.Parent.Plr.Value.. "ball"
local existingGroup = game:GetService("PhysicsService"):IsCollisionGroupRegistered(groupName)

if existingGroup then
	
	script.Parent.CollisionGroup = groupName
	else
	
	game:GetService("PhysicsService"):RegisterCollisionGroup(groupName)
	script.Parent.CollisionGroup = groupName
	end

local playergroup = script.Parent.Plr.Value

local playerexist = game:GetService("PhysicsService"):IsCollisionGroupRegistered(playergroup)
if playerexist then
	game:GetService("PhysicsService"):CollisionGroupSetCollidable(playergroup,groupName, false)
end

while true do
	wait(1)
	for _, group in ipairs(game:GetService("PhysicsService"):GetRegisteredCollisionGroups()) do
		if group.name ~= "default" then
			game:GetService("PhysicsService"):CollisionGroupSetCollidable(groupName,tostring(group),false)
		end
	end
end

i think it is the “group” that is the problem

Yes you’re right, you should use group.name instead of just group or tostring(group) inside the CollisionGroupSetCollidable

oh yeah i did that and then it started to fall off when i added this:

while true do
	wait(1)
	for _, group in ipairs(game:GetService("PhysicsService"):GetRegisteredCollisionGroups()) do
	
		if group.name ~= "default" and group.name ~= playergroup then
			game:GetService("PhysicsService"):CollisionGroupSetCollidable(groupName,group.name,false)
		end
	end
end

OH ITS NOT CAPITAL the default is not captial

hahaha easy to overlook stuff like that, glad it’s fixed!

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