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

How can I make a model with semi-transparent parts temporarily invisible?

I have a model with some parts semi-transparent and some not. I want to temporarily make it invisible, then make it visible again while keeping the transparency of the semi-transparent parts. Would I have to for loop the model and save the transparencies, make all of them transparent, then for loop the model again and set each of the transparencies? Is there a better/more efficient/more practical way to do this?

1 answer

well you can save properties like this

local savedproperty = script.parent.part.Transparency -- the local is a number that was the property. It cannot be changed unless something changes it like savedproperty = .5

script.parent.part.Transparency = 1 -- setting the part invisible
wait(5)
script.parent.part.Transparency = savedproperty -- setting the part to the saved property

you can make it looped using while loop

local savedproperty = script.parent.part.Transparency -- the local is a number that was the property. It cannot be changed unless something changes it like savedproperty = .5

while wait(5) do
	script.parent.part.Transparency = 1 -- setting the part invisible
	wait(5) -- it will flicker every 5 seconds
	script.parent.part.Transparency = savedproperty -- setting the part to the saved property
end

to detect each part that has a set transparency do something like

local savedproperty = script.parent.part.Transparency -- the local is a number that was the property. It cannot be changed unless something changes it like savedproperty = .5
local model = script.parent:GetChildren()

for i, v in pairs(model) do -- looking through every child of the model
	if v.Transparency >= .1 -- if Transparency is over 0.1
		while wait(5) do
			v.Transparency = 1 -- setting the part invisible
			wait(5) -- it will flicker every 5 seconds
			v.Transparency = savedproperty -- setting the part to the saved property
		end
	end
end

I hope this helps. Good luck!

1 comment

0

Not sure if this is exactly what I am looking for but it's given me a pretty good idea of how I should write the script and what the bare minimum I would have to do would be. Thanks.

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