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

How to make all the parts' transparency become 0?

Asked by 10 years ago

The title says everything... Thanks for reading.

2 answers

Log in to vote
1
Answered by
SanityMan 239 Moderation Voter
10 years ago

If you want to make all the parts invisible, I think a for loop is a great way to go.

local parts = script.Parent:GetChildren() --This will find all of the children of the script's parent
for i = 1,#parts do --The for loop will run for as many times as there are objects in 'parts'
    if parts[i]:IsA("Part") then --if the specific object is a "Part" then 
        parts[i].Transparency = 1 --makes part invisible
    end
end

In this example script, the script gets the children of its parent. It then checks if they are parts, and if they are it sets their transparency to 1. If you were to use this script, you would have to place the script in the directory of whatever group of parts you want to make invisible. You might also want to have a trigger for it if you are not just setting it that way at the beginning of the game. For that, you could use a function, which might look something like this:

function invisible()
    local parts = script.Parent:GetChildren()
    for i = 1,#parts do
        if parts[i]:IsA("Part") then
            parts[i].Transparency = 1
        end
    end
end

function onChatted(message, player)
    if message == "invis" then --if the chat message is 'invis' then
        invisible() --runs the function 'invisible' that we created
    end
end

game.Players.PlayerAdded:connect(function(player) --this stuff connects the chatted function
    player.Chatted:connect(function(message) onChatted(message, player) end)
end) 

That is just one way that you might control when your invisibility happens. Of course, if you just wanted it to run at the start of the game, you could just use the first example of the script.

0
Thank you so much! I'd upvote you, but I need 1 reputation... VitaminaT 0 — 10y
Ad
Log in to vote
-2
Answered by
painzx3 43
10 years ago

Well you can use a script, for example

local p = game.Workspace.part --Whatever the part's name may be
p.Properties.Reflectance = 0
end

This might not work since I did not type this in studio but you can just highlight all the parts and go to their properties and change the reflectance to 0.

Answer this question