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

How do I make all of these parts in a model transparent?

local model = script.Parent.Parent
local brick = script.Parent
local gui = brick.BillboardGui
local click = brick.ClickDetector
local text = gui.TextBox
local scroll = gui.Scroll
local click = script.Parent.ClickDetector
local branches = script.Parent.Parent.branches:GetChildren()
scroll.Size = (UDim2.new(0,5,0,5))

local function onMouseClick(player)
	text.Text = "Harvesting..."
	scroll.Size = (UDim2.new(0.1,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.2,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.3,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.4,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.5,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.6,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.7,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.8,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(0.9,5,0,5))
	wait(0.5)
	scroll.Size = (UDim2.new(1,5,0,5))
	wait(0.5)
	brick.Transparency = 1
	brick.CanCollide = false
	scroll.Size = (UDim2.new(0,5,0,5))
	text.Text = "Harvested!"
	
	wait(1) -- Split
	
	branches.Anchored = false
	branches.Transparency = 0.1
	wait(0.1)
	branches.Transparency = 0.2
	wait(0.1)
	branches.Transparency = 0.3
	wait(0.1)
	branches.Transparency = 0.4
	wait(0.1)
	branches.Transparency = 0.5
	wait(0.1)
	branches.Transparency = 0.6
	wait(0.1)
	branches.Transparency = 0.7
	wait(0.1)
	branches.Transparency = 0.8
	wait(0.1)
	branches.Transparency = 0.9
	wait(0.1)
	branches.Transparency = 1
	branches.CanCollide = false
	model:Destroy()
	print("killed")
end

click.MouseClick:connect(onMouseClick)

1 answer

There are a few ways to do this, but one way would be to loop through all of the parts and change their transparency.

--Changes the transparency of all of the branches
for i,v in pairs(branches) do
	v.Transparency = 0.1
end

I see you also have a repeating phrase, which can be changed to make it much cleaner.

--Changes the transparency of all the branches while making them slowly disappear
for i = 0.1, 1, 0.1 do
	for i,v in pairs(branches) do
		v.Transparency = i
	end
	wait(0.1)
end

Hopefully this helps! :D If you have any questions, please ask.

2 comments

0

doesnt work

0

Which part?

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