How Can I Update My Collison Group Script?

Hey Developers my Collision group script is now deprecated and I was wondering how I could change it to no longer be deprecated? Heres the script

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

Players.PlayerAdded:Connect(function(player)
	for i, object in ipairs(player:GetDescendants()) do 
		if object:IsA("BasePart") then 
			PhysicsService:SetPartCollisionGroup(object, "Players")
		end
	end
end)

I know that “SetPartCollisionGroup” Needs to be changed to object.Collision group but I’m unsure how to do this since the devforum post didn’t explain well enough for me to understand it.

A:

This should work:
local PhysicsService = game:GetService(“PhysicsService”)
local Players = game:GetService(“Players”)

Players.PlayerAdded:Connect(function(player)
for i, object in ipairs(player:GetDescendants()) do
if object:IsA(“BasePart”) then
object.CollisionGroupId = PhysicsService:GetCollisionGroupId(“Players”)
end
end
end)

1 Like

Maybe just object.CollisionGroup = “Players”? idk if that would work

1 Like

I tryed that and it didnt work

Didn’t seem to work sadly got anymore suggestions?

All you have to do is replace this

		if object:IsA("BasePart") then 
			PhysicsService:SetPartCollisionGroup(object, "Players")
		end

with this

		if object:IsA("BasePart") then 
			object.CollisionGroup = "Players"
		end

Also put your script in a characteradded event.

Player.CharacterAdded:Connect(function(Character)
	-- Load their character after it died
	local Humanoid = Character:WaitForChild("Humanoid")
	Humanoid.Died:Connect(function()
		Player:LoadCharacter()
	end)
	-- Wait for character to be parented to workspace
	repeat
		task.wait()
	until Character.Parent ~= nil
	-- Loop through all character limbs and make player non-collideable
	for _, Object in Character:GetDescendants() do
		if not Object:IsA("BasePart") and not Object:IsA("MeshPart") then continue end
		Object.CollisionGroup = "Players"
	end
end)
1 Like

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