Make only certain player non collidable

I want to make a certain player non collidable, so other players cannot collide with the target player but can collide with everyone else. I tried setting body parts can collide off, but it instantly reverts. Also using PhysicsService won’t work as it will make every player in the collision group non collidable, but I only want one player to not be able to collide with everyone else, but everyone else can collide.

You can also do this for only 1 player:

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

PhysicsService:CreateCollisionGroup("NonCollidablePlayer")
PhysicsService:CreateCollisionGroup("Players")

for i, client in pairs(Players:GetPlayers()) do
	if client.BoolValue.Value then -- This is just an example, put in here anything that can difference the player apart from everyone else.
		for i, obj in pairs(client.Character:GetDescendants()) do
			if obj:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(obj, "NonCollidablePlayer")
			end
		end
	else
		for i, obj in pairs(client.Character:GetDescendants()) do
			if obj:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(obj, "Players")
			end
		end
	end
end

PhysicsService:CollisionGroupSetCollidable("Players", "NonCollidablePlayer", false)
1 Like