Model Visibility Problem

Hi developers!

Disclaimer: I’m a beginner, so there might be a small mistake that’s obvious and I didn’t know about.

So I’m trying to make a button that “opens” a door by disabling CanCollide and Visibility for certain parts of the door. However, the window frame model of my door is not disappearing like it should when I click the button in game - only the other parts that I want disappear.

Here’s my code:

local door = game.Workspace.FactoryDoor.Door
local window = game.Workspace.FactoryDoor.WindowFrame:GetChildren()

ClickDetector.MouseClick:Connect(function()
	door.Transparency = 1
	door.CanCollide = false
	window.Visible = false
	window.CanCollide = false

Note: “WindowFrame” and “FactoryDoor” are models, and “Door” is a part within the “FactoryDoor” model.

I took this video: Sorry about the low quality - I was using the Roblox Studio built-in recording tool.

robloxapp-20200606-1559052.wmv (3.5 MB)

Also, if this makes any difference, I used a plugin called Gap Fill to make my “WindowFrame” model.

Any solutions to my issue? Thanks in advance!

If you want to make parts in a model transparent, you are going to need to iterate through each one with a for loop.

IE:

for i, part in pairs(window) do
	part.Visible = false
	part.CanCollide = false
end

( this is using your window variable table of the window model’s children )

Thanks!

I used the code you provided and changed “visible” to “transparency” and it worked!