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

How do I make a model transparent?

I am trying to make a model that disappears and you can't collide with when clicked on.

1 comment

0

An idea is to create a quick table of all parts inside the model using GetDescendants.

2 answers

First create a table of all parts you want to make transparent, so you want to get all parts inside the model. In Order to do that, do the following:

ModelParts = game.YourModel:GetDescendants() --[[This is a table with every Part inside the Model.]]

for _,Part in pairs(ModelParts) --Loop through every Part.
do
Part.Transparency = 1 --Make the Part invisible
Part.CanCollide = false --Make the Part not collidable.
--You can alternatively Destroy the Part by using Part:Destroy()
end

Well you would need to loop through all the children of the model and make them transparent and turn CanCollide off.

Example:

Car (model)

-Windscreen (part)

-Chassis (part)

-Body (part)

-Wheels (model)

This is the model of a car, lets say.

Here is the script I would put inside the car model:

-- serverscript in the car model
local CarModel = script.Parent

for i, v in pairs(CarModel:GetChildren()) do
	if v:IsA("Part") then
		v.Transparency = 1
		v.CanCollide = false
	
	elseif v:IsA("Model")
		for k, part in pairs(v:GetChildren()) do
			if v:IsA("Part")
				part.Transparency = 1
				part.CanCollide = false
			end
		end
	end
end)

The above script loops through everything in the model and checks if its a part, if it's a part, it will be turned transparent and CanCollide off, if it's another model (the wheels for example) it will loop through that model and then make it transparent and cancollide off.

Hope this helps!

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