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

How to change properties of a model?

Asked by 8 years ago

I am trying to make an entire model transparent from steeping on a brick. I'm not sure how to do this though. Is it possible?

2
use a for loop theCJarmy7 1293 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago
local Model         = workspace:WaitForChild'model name here'
local Brick         = workspace:WaitForChild'name of brick here'
local Debounce  = false


function changeTransparency(Value)
    if Model and Value and type(Value) == "number" then
        for i,v in next,Model:GetChildren() do

            if v.ClassName == "Part" then
                v.Transparency = Value
            end

        end

    end
end




Brick.Touched:connect(function(Part)
    if Part and Part.Parent.ClassName == 'Model' and Part.Parent:FindFirstChild'Humanoid' then
        if not Debounce then
        Debounce = true
        changeTransparency(1)

        wait(.5)
        Debounce = false
        end
    end
end)


basically just use a for loop to iterate through all the model's children and check if they are Part instances and change their Transparency property to 1

Ad
Log in to vote
0
Answered by 8 years ago

What I would do is have it select each part of that model and change its transparency. Inefficient script, but I'm not the best either. You could do something like this

Part.Transparency = 1
Parta.Transparency = 1

and so on, again, that's a horrible way to do it, but that's what I do. (If anyone else wants to show me a better way of doing this, please do!)

0
I recommend the answer above yours for guidance.. :) legosweat 334 — 8y

Answer this question