Part collision problem

I made a script so my trunk, which is a group, can open by having 2 of them and making one transparent. The problem is that the collision doesn’t work and the Transparency does.

local trunk1 = script.Parent.Parent.Parent.Parent:WaitForChild('TDoor1')
local trunk2 = script.Parent.Parent.Parent.Parent:WaitForChild('TDoor2')
local click = script.Parent
click.Enabled = true

for _, Child in pairs(trunk2:GetChildren()) do
	Child.Transparency = 1
end

click.Triggered:Connect(function()
	for _, Child in pairs(trunk1:GetChildren()) do
		Child.Transparency = 1
		Child.CanCollide = false
	end
	for _, Child in pairs(trunk2:GetChildren()) do
		Child.Transparency = 0
		Child.CanCollide = true
	end
	click.Enabled = false
end)

Actually in-game some parts of the vehicle like the roof and the seats don’t have collision but the properties window says they have. Maybe the problem is something else.

Any solution?

What do you mean? its working fine I tested it, maybe GetDescendants() would be better.

prompt.Triggered:Connect(function()
	for _, part : Part in model1:GetDescendants() do
		if not part:IsA("BasePart") then continue end
		
		part.Transparency = 1
		part.CanCollide = false
	end
	
	for _, part : Part in model2:GetDescendants() do
		if not part:IsA("BasePart") then continue end
		
		part.Transparency = 0
		part.CanCollide = true
	end
	
	prompt.Enabled = false
end)

Thank you but CanCollide doesn’t work for me. I think it might be an engine bug. All the vehicle parts have CanCollide to true but some of them seem to not have collision even if CanCollide is true.

Edit: When i removed a part that it’s collision didn’t work from the vehicle group, it’s collision works now,
so maybe a model bug.

Edit2: Well i found the problem. The unions had a problem with collision. I separated them and re-union them and now collision works

1 Like