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

How do I make a model transparent?

Asked by 4 years ago

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

0
An idea is to create a quick table of all parts inside the model using GetDescendants. MinecraftButterfly87 10 — 4y

2 answers

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

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
Ad
Log in to vote
0
Answered by 4 years ago

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!

Answer this question