I'm making a group of walls that are only supposed to allow players in by putting all their parts into a collision group. It works, but it often glitches and doesn't allow my player to walk through at all. Here's my current script, it's a server script put into a model.

local boundries = script.Parent.Boundries
local Field = script.Parent.Field
physics = game:GetService("PhysicsService")
players = game:GetService("Players")
local plrs = "Players"
physics:CreateCollisionGroup(plrs)
local wls = "boundries"
physics:CreateCollisionGroup(wls)
physics:CollisionGroupSetCollidable(wls, plrs, false)
physics:SetPartCollisionGroup(boundries.A, wls)
physics:SetPartCollisionGroup(boundries.B, wls)
physics:SetPartCollisionGroup(boundries.C, wls)
physics:SetPartCollisionGroup(boundries.D, wls)
players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function(Character)
		for i, child in pairs(Character:GetChildren()) do
			if child:IsA("BasePart") then
				physics:SetPartCollisionGroup(child, plrs)
				print(child.Name.." was added to '"..plrs.."'")
				physics:CollisionGroupSetCollidable(wls, plrs, false)
			end
		end
	end)
end)

Does anyone know what I'm doing wrong, or is this just a stupid glitch? Thanks.

3 comments

0

Do you want the players to go through the "boundaries" or collide with them?

0

Wait.. nevermind. Have you tried using GetDescendants() instead, as maybe hats, for example get blocked.

0

Hats always have cancollide set to false on them, so even if I do add them they won't be affected by collision groups... Also only baseparts can be added to collision groups