No Collison with Cars from other Players

Hey guys, i never used collison groups before but now im on the point that i need them.
So it is about Cars, the Cars are usually not collideable but the Rims should’t dont fall trough the Road or map.
So the Rims are collideable.
Can someone help me or give me a lil script to make the Rims Uncollideable to other Rims so Cars cant crash into other Cars?

Got a question I am making a script, but I dont know if you want the cars to collide with the players or not. Got a preference?

1 Like

Doesnt matter lol you can add them to the collision group if you want

local Phys = game:GetService("PhysicsService")

Phys:CreateCollisionGroup("ObjectNoCollide")
Phys:CollisionGroupSetCollidable("ObjectNoCollide","ObjectNoCollide",false)

function SetPartCollision(Part)
	if v:IsA("BasePart") then
		Phys:SetPartCollisionGroup(Part,"ObjectNoCollide")
	end
end

function Givemodelnoplrcollision(modl)
	for i,v in pairs(modl:GetDescendants()) do
		SetPartCollision(v)
	end
end

--Just call the function with an object to add to the collision group

local Part = game.Workspace.Part
Givemodelnoplrcollision(Part)

Edit: AHH sorry i made a mistake xd

First, thanks for your help!

Cars should not collide with other Cars and as example…
I want that Players can drive through other Player Cars without collision problems uk ?
The Rims are the only last problem because they collideable, but they have to.
So i want that rims cant collide with other rims, only with the Road, Map, Terrain.

Yeah okay
My code should work for that, but I made the code for models so you might have to put rims into models.
If you cant do that you should be able to just run the set part Collision.

and you can just add players to it later if you like
just anything you do not want to collide with each other —> functions

Will this Work?


--Just call the function with an object to add to the collision group
local player = game.Players
local Part = game.Workspace:FindFirstChild(player.Name.."'s Car")
local Wheels = Part.Wheels
for i,v in pairs(Wheels:GetDescendants()) do
	if v:IsA("BasePart") then
		Givemodelnoplrcollision(Wheels)
	end
end

Screenshot (91)
These are the Rims they must be uncollideable with other Rims

Yea that will, but I tried making it a little easier for you

Your script →

local player = game.Players
local Part = game.Workspace:FindFirstChild(player.Name.."'s Car")
local Wheels = Part.Wheels
Givemodelnoplrcollision(Wheels)

id probably rename the function I am picky about it sometimes xd

okay but ig this will not work because the “Wheels” is just a model ?
im not sure

Well it will because I had :GetDescendants in my function so it already sets the collisions of every object inside the model

so its sets the collisions of every object in the wheels model

Mhm if you wanted to do a single object you could just call

SetPartCollision(Part)

Yea xd ik, but need the 4 rims in the Wheels model set to non collidable.
Alright I’ll test it now

Sure how can i help test it?
xd

xd lol ig i removed the comment
anyway uh i published it to my game so maybe u can join and we can test that it works right

function Givemodelnoplrcollision(modl)
	modl.DescendantAdded:Connect(SetPartCollision)
	for i,v in pairs(modl:GetDescendants()) do
		SetPartCollision(v)
	end
end

thats all it is

Thats the Current script:

local Phys = game:GetService(“PhysicsService”)

Phys:CreateCollisionGroup(“ObjectNoCollide”)

Phys:CollisionGroupSetCollidable(“ObjectNoCollide”,“ObjectNoCollide”,false)

function SetPartCollision(Part)

Phys:SetPartCollisionGroup(Part,“ObjectNoCollide”)

end

function Givemodelnoplrcollision(modl)

modl.DescendantAdded:Connect(SetPartCollision)

for i,v in pairs(modl:GetDescendants()) do

SetPartCollision(v)

end

end

–Just call the function with an object to add to the collision group

local player = game.Players

local Part = game.Workspace:FindFirstChild(player.Name…"'s Car")

local Wheels = Part.Wheels

Givemodelnoplrcollision(Wheels)

New Line:

--Just call the function with an object to add to the collision group
local player = game.Players
local Part = game.Workspace:FindFirstChild(player.Name.."'s Car")
Givemodelnoplrcollision(Part)

Yea that should work lets see if it works!

1 Like

Screenshot (93)
This is how the Car looks when it is spawned by player in workspace

mine looks like this

local Phys = game:GetService("PhysicsService")

Phys:CreateCollisionGroup("ObjectNoCollide")
Phys:CollisionGroupSetCollidable("ObjectNoCollide","ObjectNoCollide",false)

function SetPartCollision(Part)
	if Part:IsA("BasePart") then
		Phys:SetPartCollisionGroup(Part,"ObjectNoCollide")
	end
end

function Givemodelnoplrcollision(modl)
	modl.DescendantAdded:Connect(SetPartCollision)
	for i,v in pairs(modl:GetDescendants()) do
		SetPartCollision(v)
	end
end