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

How to make all the parts' transparency become 0?

The title says everything... Thanks for reading.

2 answers

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.

1 comment

0

Thank you so much! I'd upvote you, but I need 1 reputation...

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.

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