CollisionGroup help!

Hello!

So basically I kinda suck with CollisionGroups, but ignoring this, I wanted a part that’s being cloned from ReplicatedStorage to not collide with players, however, it keeps throwing me an error which I don’t really understand. Can someone help?

Here is my script.

--local script in StarterGUI

local fakeHand = game:GetService("ReplicatedStorage"):WaitForChild("fakeHand")

function MakeFakeHand()
	local newHand = fakeHand:Clone()
	newHand.Parent = player.Character
	newHand.CFrame = player.Character:WaitForChild("RightHand").CFrame

	--Fire server for newHand collision group properties.
	game.ReplicatedStorage:WaitForChild("newHandEvent"):FireServer(newHand)

	local weld = Instance.new("WeldConstraint", newHand)
	weld.Part0 = newHand
	weld.Part1 = player.Character:WaitForChild("RightHand")
end

MakeFakeHand()

--Server script in ServerScriptService

task.wait(0.1) --Wait for "Players" collision group to load (doesn't seem to work though).

local PhysicsService = game:GetService("PhysicsService")

game.ReplicatedStorage.newHandEvent.OnServerEvent:Connect(function(plr, newHand)
	--Set collision status of newHand to not collide with players.

	local newHandcollisionGroup = PhysicsService:CollisionGroupSetCollidable("newHandCollisionGroup", "Players", false)
	PhysicsService:SetPartCollisionGroup(newHand, newHandcollisionGroup)
end)

It keeps saying throwing an error that says, “Both collision groups must be registered.” and I really don’t know how to fix it.

You wpuld need to create and set up a CollisionGroup with RegisterCollisionGroup

Have to register them like this:

	PhysicsService:RegisterCollisionGroup("newHandCollisionGroup")
	PhysicsService:RegisterCollisionGroup("Players")

Can do this once at runtime or with the collision editor ui in studio

1 Like

But I already did in the collision editor UI. The players collision group is created by another script that disables player collisions.

Yes, but it says: Both CollisionGroups must be registered which means one (or both) of them is not registered.

You are either firing the code prior to its registration, or you haven’t created it yet

2 Likes

Ohhhhh you know what I did? I accidentally renamed the collision group that I was calling in the script newHandCollisionGroup while the collision group itself was fakeHandCollisionGroup…

Sorry guys, my mistake!!

However, I do have a new problem where it throws an error saying Parameter 1 must be BasePart in SetPartCollisionGroup.

task.wait() --Wait for "Players" collision group to load.

local PhysicsService = game:GetService("PhysicsService")

game.ReplicatedStorage.newHandEvent.OnServerEvent:Connect(function(plr, newHand)
	--Set collision status of newHand to not collide with players.

	PhysicsService:CollisionGroupSetCollidable("fakeHandCollisionGroup", "Players", false)
	PhysicsService:SetPartCollisionGroup(newHand, "fakeHandCollisionGroup")
end)

I don’t know why because newHand is a part.

Just so you know:
This function is Deprecated, you should instead do this:

newHand.CollisionGroup = "fakeHandCollisionGroup'

Now it says attempt to index nil with CollisionGroup.

Well, if you are creating the Part on the Client, you are basically giving the Server a nil value as it doesnt exist there, so you should probably create it on the server.