Player Collision Group

Hi guys,

I found this interesting bug or error ? Or maybe just I dont know where is problem.

I am using collision groups to make some invissible wall to prevent objects go throught that but I want Players are able to go through this wall. In my studio everything works fine but in server not. I disabled every collision but player still cannot go throught that.

I also found “noclip” group and disable this group to collide but it doesnt work.

Can somebody help me with my problem ? Thank you for every answer

3 Likes

I am not sure 100% what you are asking for help with, can you try wording it better or provide photos?
If you are trying to make parts collide with each other whilst others cannot, you can use the built-in Roblox tab for that.
colgroups
Simply go to the Model tab then select Collision Groups. You can use this tab to change how BaseParts collide with each other, assuming you have them setup to join the collision group.

I would highly recommend having a look at Roblox’s API page for Physics Service too.

2 Likes

This is not what I am looking for. My problem is for example this wall:


When I start it in roblox studio I can go inside it:

But when I publish it and play from roblox site then I cannot go inside:

1 Like

What are you using to give parts their collision group?

Wall have set up group in Propertie tab:
image
Player is insert into group by this script from original roblox development site:

but its edited in collision groups:
image

1 Like

As per this page states, you shouldn’t modify CollisionGroupId

Instead, use physicsService:SetPartCollisionGroup(part, name) on startup.

If that does not fix you might have to take a look at the script thats assigning the Players collision group.

1 Like

You mean, set up wall CollisionGroupId to 0 and istead of this set up it by script ?

Yeah, but instead of changing CollisionGroupId, leave it how it is and try the script method.
Also note that SetPartCollisionGroup(part, name) uses two arguments. The name argument takes the collision group name in a string. Do not provide a collision group id for this part.

Its working for roblox studio but not in real game.


Its really weird.

I’m not really an expert put have you tried using

if RunService:IsServer() then -- An if statement?
    -- Rest of the code
end

I don’t know, maybe I’m just being stupid at this point

image
Collision between Players and PiranhaFence. When false I can go inside when true I cant so working fine. I leave it false, publish to roblox, play from site and I cant go iside

Did you later update the game?

What do you mean by this. I am publishing it so game is updated. With this I never had a problem

Hm that’s weird. I assume it’s a bug then because not colliding in studio but colliding in game. Kinda weird

1 Like

This how it looks like in real game

Can I see your code that assigns the part’s collision group?

Yes, but it is just copied code from site above and 2 lines are commented:

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

local playerCollisionGroupName = "Players"
--PhysicsService:CreateCollisionGroup(playerCollisionGroupName)
--PhysicsService:CollisionGroupSetCollidable(playerCollisionGroupName, playerCollisionGroupName, false)

local previousCollisionGroups = {}

local function setCollisionGroup(object)
	if object:IsA("BasePart") then
		previousCollisionGroups[object] = object.CollisionGroupId
		PhysicsService:SetPartCollisionGroup(object, playerCollisionGroupName)
	end
end

local function setCollisionGroupRecursive(object)
	setCollisionGroup(object)

	for _, child in ipairs(object:GetChildren()) do
		setCollisionGroupRecursive(child)
	end
end

local function resetCollisionGroup(object)
	local previousCollisionGroupId = previousCollisionGroups[object]
	if not previousCollisionGroupId then return end 

	local previousCollisionGroupName = PhysicsService:GetCollisionGroupName(previousCollisionGroupId)
	if not previousCollisionGroupName then return end

	PhysicsService:SetPartCollisionGroup(object, previousCollisionGroupName)
	previousCollisionGroups[object] = nil
end

local function onCharacterAdded(character)
	setCollisionGroupRecursive(character)

	character.DescendantAdded:Connect(setCollisionGroup)
	character.DescendantRemoving:Connect(resetCollisionGroup)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

and this for wall:

local PS	= game:GetService("PhysicsService")

PS:SetPartCollisionGroup(script.Parent,"PiranhaFence")

Use this to assign player’s collision group instead.
(Disable the scripts you have in your current game before adding this one)
Make sure you are doing this in a normal script too, not a local script

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

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		for _,BasePart in pairs(Character:GetDescendants()) do
			if BasePart:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(BasePart, "Players")
			end
		end
	end)
end)

And for the wall, try this:

local PhysicsService = game:GetService("PhysicsService")

PhysicsService:SetPartCollisionGroup(script.Parent, "PiranhaFence")

Let me know how it goes, if it still does not work, it may be a Roblox bug.

Same result as on video before. Nothing changed :frowning:

So have you some else solution ?

Did you disable the scripts that were in game before you added the new one? If you did then I don’t know what is causing problems. You might have to leave it as a Roblox bug.

1 Like