Little help with collision groups...?

Hello, I’m working on an SCP and currently I need the SCP to not collide with the floor.

At the moment, this is what happens:
https://gyazo.com/7167bf94c856c4f0f38bdaf8b3ee0a57

The SCP isn’t supposed to go under the baseplate, It’s supposed to slide on the baseplate.

Anyway, I then got told to use CollisionGroups, so I got working on it.

local Model = script.Parent

local PhysicsService = game:GetService("PhysicsService")
local Gegegegegegegegeg = "Obstacles"
local okkkkkkkkkkkkk = "SomeRandomObject"
pcall(function()
  PhysicsService:CreateCollisionGroup("Gegegegegegegegeg")
  PhysicsService:CreateCollisionGroup("okkkkkkkkkkkkk")
end)

for i,v in pairs(Model:GetChildren()) do
if v:IsA("BasePart") and v.Name == "CensorPart" or "Glow" or "HumanoidRootPart"    then
PhysicsService:SetPartCollisionGroup(workspace.BetterBasePlates, Gegegegegegegegeg)
PhysicsService:SetPartCollisionGroup(v, okkkkkkkkkkkkk)
    
    end
end

I also have a CollisionGroup set up, if I click BlueObject, it selects my SCP (which is intended) and if I click obstacles, it selects my BasePlate (which is also intended). So, I am quite confused.

The error that I am currently getting is this:

Collision group does not exist.
2 Likes

Well currently you defined your two variables like so:

However when creating the collision groups, you use the variable names and not the actual collision group names:

Then of course, these collision groups haven’t been created, but you still use them:

I fixed the error, this is the updated code:

warn("gdfgdfgdfgdf")
local Model = script.Parent

local PhysicsService = game:GetService("PhysicsService")
local Gegegegegegegegeg = "Obstacles"
local okkkkkkkkkkkkk = "SomeRandomObject"
pcall(function()
  PhysicsService:CreateCollisionGroup(Gegegegegegegegeg)
  PhysicsService:CreateCollisionGroup(okkkkkkkkkkkkk)	


for i,v in pairs(Model:GetChildren()) do
if v:IsA("BasePart") and v.Name == "CensorPart" or "Glow" or "HumanoidRootPart"	then
PhysicsService:SetPartCollisionGroup(workspace.BetterBasePlates, Gegegegegegegegeg, true)
PhysicsService:SetPartCollisionGroup(v, okkkkkkkkkkkkk)
	
		end
	end
end)

However, the SCP still goes under the baseplate. I don’t know if I set up the collision groups incorrectly.

1 Like

It will really help both us and your future self out if you name your variables something meaningful, or at least give them a name which isn’t an arbitrary number of repeating characters that will inevitably get mistyped and be really difficult to spot! I guarantee at some point you’re going to get weird errors in your collisions groups because you accidentally put ‘okkkkkkkkkkkk’ instead of ‘okkkkkkkkkkkkk’ somewhere.

4 Likes

I did name them something more “useful” however, I kept getting the same error:

 10:57:14.249 - Could not create collision group, one with that name already exists.

Well you say you already created them in the editor plugin, so are you then trying to create the same groups again via code? Also how does your SCP actually move?

Yes, the SCP does move. (30 chars)

What are you using to make it move though?

Pathfinding and TweenService. (30 chars)

If you’re using TweenService then presumably that means it’s being moved with Position or CFrame, which don’t interact with physics. So your issue here isn’t really anything to do with collision groups, and is instead to do with your pathfinding or tweening code.

In my case because the game I am developing for has this exact same object, we move it with body movers. This is fairly effective considering body movers and collisions both fall under the physics pipeline, so they fit hand in hand. I wouldn’t say TweenService is great to use here, that’s more suited to statically moving objects.

1 Like

Body Movers you say? Interesting. Thank you.