How to make a model only collide with parts?

Hi! I am making a tycoon game in Roblox and I have a model that I want to collide with parts and not players.

The reason why I want to achieve this is that there might be issues later on if the player can kick the object off of the tycoon.

I have a model with all the components within that is unanchored and this model is the object that moves down the tycoon for money. I want a script that can affect the model as a whole and not a specific object in the model. And I am interested in having the raw code than resource links, it just makes it easier.

If all is possible, thanks! Otherwise have a great day!

1 Like

Maybe try using CollisionGroupId:
https://developer.roblox.com/en-us/api-reference/property/BasePart/CollisionGroupId

How would I script this into my model?

Edit: It looks very complicated and I don’t know where to start.

It’s pretty easy, don’t retay. Here is a video as an example:

You can search for more tutorials, Good Luck!

Here

local PhysicsService = game:GetService("PhysicsService")

CollisionGroup = "Parts"
PlayerCollisionGroup = "Players"
PhysicsService:CreateCollisionGroup(CollisionGroup)
PhysicsService:CreateCollisionGroup(PlayerCollisionGroup)
PhysicsService:CollisionGroupSetCollidable(CollisionGroup, PlayerCollisionGroup, false)
 
local function setCollisionGroup(object , group)
	if object:IsA("BasePart") then
		if group == "parts" then PhysicsService:SetPartCollisionGroup(object, CollisionGroup)
		elseif group == "Player" PhysicsService:SetPartCollisionGroup(object, PlayerCollisionGroup)
		end
	end
end
 
local function setCollisionGroupRecursive(object , group)
  setCollisionGroup(object , group or "parts")
 
	for _, child in ipairs(object:GetChildren()) do
		setCollisionGroupRecursive(child  , group or "parts" )
	end
end

--when cloning the model just do setCollisionGroupRecursive(model , "parts")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		setCollisionGroupRecursive(character , "Player")
	end)
end)

Would I put this under ServerScriptService or would I put it under the model that I want to have these properties and I am guessing it is a server script and not a local one?

ServerScript, in the script where you clone your spiders

How would I add this to a model that will have many versions of itself because it will be cloned? In the video he assigned the part through the workspace, would I be able to do script.parent, or something instead, or would that not work?

Like this?

part:Clone(setCollisionGroupRecursive(model , "parts"))

No no, model was a reference to your item, do this

setCollisionGroupRecursive(part:Clone() , "parts")