How would I make it where I can get every part in a folder and make all of them transparent in a script. So lets say I have 50 parts in a folder and I want all of them to turn transparent. Is there anyway I can do this?
3 Likes
You can loop through the folder and check if they are a part.
for i, v in pairs(game.LOCATION_OF_FOLDER:GetChildren()) do
if v:IsA("Part") then
v.Transparency = 1
end
end
6 Likes
It works but why wouldn’t something like this work?
while true do
for i, v in pairs(game.Workspace.DisapearingParts:GetChildren()) do
if v:IsA("Part") then
v.Transparency = 1
wait(1)
v.Transparency = 0
wait(10)
end
end
end
2 Likes
Well I mean it depends on your definition of work.
I assume the script you provided here you intend to instantly make all parts invisible, then wait 1 second, then make them visible again.
However, the way you’ve scripted this, you’re telling the script to take the first part in the Folder, make it invisible, wait 1 second, make it visible, wait 10 seconds, then go to the second part.
Here is a very simple implementation of getting all parts to “Flicker” almost. Keep in mind there are probably 100 different ways to do this more efficiently however for simplicity sake here are the basics.
local function makeInvisible()
for _, possiblePart in pairs(workspace.DisapearingParts:GetChildren()) do
if possiblePart:IsA("BasePart") then
possiblePart.Transparency = 1
end
end
end
local function makeVisible()
for _, possiblePart in pairs(workspace.DisapearingParts:GetChildren()) do
if possiblePart:IsA("BasePart") then
possiblePart.Transparency = 0
end
end
end
while true do
makeInvisible()
task.wait(1)
makeVisible()
task.wait(10)
end
4 Likes