Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a Part non-CanCollide to a part only through scripting?

Asked by 3 years ago

Let me explain my question.We have Part A, B, and C. What I wanted to do is that Part B is non-CanCollide to Part A only while it can collide with Part C. I am new to scripting and I can't make up my own script.

0
do you know how to script? Zeuxulaz 148 — 3y
0
I know how the basics. Gam3r_Play3r 47 — 3y
0
I am talking about how a part can and cannot collide with other parts Gam3r_Play3r 47 — 3y
0
just turn off cancollide in part a? Warphi 51 — 3y
0
Just look at the cars in electric state RP, the wheels can collide with the ground while it cannot collide with the cars' body, but the cars' body has enabled can collide. Gam3r_Play3r 47 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You will need PhysicService for that

https://developer.roblox.com/en-us/api-reference/class/PhysicsService

What this does is basically allows you to create groups and set their rules

example :

local PartA = --Part A here
local PartB = --Part B here
local PartC = --Part C here

local PhysicService = game:GetService("PhysicsService")
--That will call the service that will provide us with the functions that we need

PhysicService:CreateCollisionGroup("GroupA")
PhysicService:CreateCollisionGroup("GroupB")
PhysicService:CreateCollisionGroup("GroupC")
--This will create collision group which we can put multiple objects in

PhysicService:CollisionGroupSetCollideable("GroupA", "GroupB", false)
--This will set a rule, any object that is set to "GroupA" cannot collide with "GroupB"

PhysicService:CollisionGroupSetCollideable("GroupB", "GroupC", false)
--This will set a rule, any object that is set to "GroupB" cannot collide with "GroupC"

PhysicService:SetPartCollisionGroup(PartA, "GroupA")
PhysicService:SetPartCollisionGroup(PartB, "GroupB")
PhysicService:SetPartCollisionGroup(PartC, "GroupC")

--This will set all the part into a collision group

-

--The end result of that script will be :
--- PartA cannot collide with PartB, but can collide with PartC
--- PartB cannot collide with PartC and PartA
--- PartC cannot collide with PartB, but can collide with PartA

--Hopefully that explanation is detailed and simple enough
0
Np Azure_Kite 885 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

game.Workspace.Part.Cancollid = true

0
CanColide is a bool value here game.Workspace.Part.Cancollid = true AtomWiley -5 — 3y
0
that wasn't useful, I already know about that script, do you have a script about collision groups? Gam3r_Play3r 47 — 3y

Answer this question