Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How i change the CanCollide property of 2 parts?

soo, i wanted to change the CanCollide property of one part trough a script,so i used:

      One = workspace.One
     One.CanCollide = false

but now, i added another Part next to One wich is basicaly an extension,so i tought i can Union them, but i cant find the Union button, anyway, when i run the game, just one of it ”works”,but i want to control both of them, so i put them both in a model called ONE and sayd:

       One =  workspace.ONE:GetChildren()
       One.CanCollide = false

But this doesent work at all, help?

2 answers

✓ Accepted answer

You can loop through the children of “ONE” and set their CanCollide property, like so:

for i, v in ipairs(workspace.ONE:GetChildren()) do
	v.CanCollide = false
end

for i, v in ipairs(workspace.TWO:GetChildren()) do
	v.CanCollide = false
end

for i, v in ipairs(workspace.THREE:GetChildren()) do
	v.CanCollide = false
end

--and so on

Check out this DevFourm post for an explanation of the loop used

3 comments

0

Hi, im very very basic at LUA, so this doesent help me whit nothing, cause idk 100% what it does.

0

I also got the TWO gropu and the THREE group, what i do whit them??

0

Edited, you can also choose to group all the groups together and loop through it using GetDescendants() instead

hey you! have you ever heard of enes? if you are in trouble, better call enes!

This discussion is preserved as it was. New answers, comments, and votes are closed.