How to Turn Off Player Collision: Quick Tutorial!

This is a quick and easy tutorial on how to make players walk through each other, with minimal bugs.

Start off by heading over to the Model tab in Roblox Studio, and click on “Collision Groups”.
image

Once you are there, depending on your version, you should see a screen like this.

At the top, go ahead and click on “Add Group”.

Type in your name, I would recommend naming it “Player Part”, and then click enter.

Once you have done that, a new Collision Group should show up on the side. Click on it, and you should see this screen.

!IMPORTANT! Make sure you toggle PlayerPart under the “PlayerPart” can collide with off.
image

Now I will have 2 tutorials. The first one will be if you are using the default character, and the second one is for if you are using a custom character.

Default Character

Head over to ServerScriptService and create a new script.
image
Name it whatever you want, I’m going to name it PlayerCollide.

Next, we need to code it. In order to do this, we need to start by defining PlayerService.

local PlayerService = game:GetService("Players") --Define Player Service

After that, we are going to check when a player joins, and make a function out of it.

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player) --Make a variable for the player
	--Todo: set player's collision
end)

We are now going to get the player’s character and make a variable for it.

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.
end)

Now, we are going to use a for i loop in order to get all the character’s parts that can collided with, and we will do it like this:

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.
	
	for _, child in pairs(Character:GetDescendants()) do
		--Todo: Check if the part needs the collision group.
	end
end)

Now, we need to check if the child it found inside of the character is a Basepart. We do this by having an if statement using the :IsA() to check if it is a Basepart.

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.
	
	for _, child in pairs(Character:GetDescendants()) do
		if child:IsA("BasePart") then
			--Todo: Set collision group.
		end
	end
end)

Now that we have verified that the child is collide able, we need to set its collision group, which is fairly simple. We will use child.CollisionGroup.

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.

	for _, child in pairs(Character:GetDescendants()) do
		if child:IsA("BasePart") then --Checks if the child is a basepart
			child.CollisionGroup = "PlayerPart" --Set "PlayerPart" to your name of your collision group.
		end
	end
end)

And now its done! Your player should not be able to collide with other player’s now, and will work perfectly fine with other parts.

Custom Character

This one is fairly simple. You can go into your custom character in StarterPlayer (or wherever it is) and just add in the collision group individually. If you do not want to do it manually, then this is the script from the default character tutorial, it should work fine for the most part.

local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.

	for _, child in pairs(Character:GetDescendants()) do
		if child:IsA("BasePart") then --Checks if the child is a basepart
			child.CollisionGroup = "PlayerPart" --Set "PlayerPart" to your name of your collision group.
		end
	end
end)

If you do not want to read, feel free to just use the script, it should just work as long as you followed the starting steps.

Script for lazy readers
local PlayerService = game:GetService("Players") --Define PlayerService

PlayerService.PlayerAdded:Connect(function(player)--Make a variable for the player
	local Character = player.Character or player.CharacterAdded:Wait() --We also add the CharacterAdded:Wait() to make sure the script get the character.

	for _, child in pairs(Character:GetDescendants()) do
		if child:IsA("BasePart") then --Checks if the child is a basepart
			child.CollisionGroup = "PlayerPart" --Set "PlayerPart" to your name of your collision group.
		end
	end
end)

Thank you for reading my tutorial, and I hope you learned something! If you have any errors, questions, or criticism, all is welcome in replies :slight_smile:

5 Likes