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

How do I make the branches slowly dissapear?

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))
val = 0

local function onMouseClick(player)
	text.Text = "Harvesting..."
	repeat
		val = val + 0.025
		scroll.Size = (UDim2.new(val, 5, 0, 5))
		wait(0.5)
		if val>=1 then
			break
		end
	until val==1
	text.Text = "Harvested!"
	brick.Transparency = 1
	brick.CanCollide = false
	scroll.Size = (UDim2.new(0,5,0,5))
	
	for i,v in pairs(branches) do
    v.Transparency = 1
	
	wait(1)
	model:Destroy()
	print("killed")
	end
end

click.MouseClick:connect(onMouseClick)

1 answer

✓ Accepted answer

Hello, iRoklas!

Try this:(EDITED)

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))
val = 0

local function onMouseClick(player)
    text.Text = "Harvesting..."
    repeat
        val = val + 0.025
        scroll.Size = (UDim2.new(val, 5, 0, 5))
        wait(0.5)
        if val>=1 then
            break
        end
    until val==1
    text.Text = "Harvested!"
    brick.Transparency = 1
    brick.CanCollide = false
    scroll.Size = (UDim2.new(0,5,0,5))
    
    for x=0, 1, 0.1 do --This will make the X value go from 0.1 to 1
        wait(0.1) --Place a time here, i recommend smaller than 0.5
        for i,v in pairs(branches) do
            v.Transparency = x
        end
    end
    wait(1)
    model:Destroy()
    print("killed")
end

click.MouseClick:connect(onMouseClick)

Hope this helps!

Good Luck with your games

5 comments

0

Workspace.Model.WoodCubeTEST.Script:27: '' expected near '1'

0

Solved, I forgot a 0 on line 27

0

It works, but it doesn't dissapear slowly, also you need to remove and 'end' at the bottom.

0

I'll edit, now i know(I forgot a wait)

0

thanks :)

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