Help with collision group script

This is my collision group script:

local ps = game:GetService("PhysicsService")

local ocean = "ocean"
local boat = "boat"
local chars = "chars"
local border = "border"

ps:CreateCollisionGroup(border)
ps:CreateCollisionGroup(ocean)
ps:CreateCollisionGroup(boat)
ps:CreateCollisionGroup(chars)

for _, v in next, game.Workspace.ocean:getChildren() do
	ps:SetPartCollisionGroup(v, ocean)
end

for _, v in next, game.Workspace.border:getChildren() do
	ps:SetPartCollisionGroup(v, border)
end

for _, v in next, game.Workspace.boat1:GetDescendants() do
	if v:IsA("BasePart") then
		ps:SetPartCollisionGroup(v, ocean)
	end
end

ps:CollisionGroupSetCollidable(ocean, boat, false)

game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	for _, v in next, char:GetDescendants() do
		if v:IsA("BasePart") or v:IsA("Accesory") then
			ps:SetPartCollisionGroup(v, chars)
			ps:CollisionGroupSetCollidable(chars, ocean, false)
			ps:CollisionGroupSetCollidable(border, chars, false)
			print("e")
		end
	end
	print("person joined")
end)

the ocean doesn’t collide with the player when I do this (as expected): ps:CollisionGroupSetCollidable(chars, ocean, false) but when I do it to border: ps:CollisionGroupSetCollidable(border, chars, false) the player still collides with it. Any idea causing the problem, why the character still could collide with the border even though I turned the collisions to false?

1 Like

making the boat not collide with the ocean also does not work, when I change the order of the part creating the collision groups I get different results each time

I don’t see why you need to check if the instance is an Accessory in the character since it goes through all the descendants… Also, I think accessories have parts inside of them which are named Handle’s, so you wouldn’t be able to change an Accessory collision, only it’s Handle and other parts inside of it. This should have already been clear since there is only one function to add an instance to a collision group which is named SetPartCollisionGroup. So, you can add any BasePart to the collision group. I suggest removing the IsA Accessory statement, it might be the whole cause of the issue.

You should probably also correct the spelling of accessory.

I removed it but to no avail, I still collide with the border.

I thought the accessories were colliding as well so that’s why I put it in the group

I fixed it I used this:

to help me solve the problem (I literally just copied the entire code and replaced the collision with the player-player with player-objectImTryingToMakePlayerNotCollideWith)