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

GUI Click sequence?

I'm not really sure where to start but the idea is. XYZ are Frames lets say.

You click once "x" shows up. Click again, "y" shows up. Then click a final time and "z" shows up.

1 answer

✓ Accepted answer

Each time we click the button, something has to happen. You want to make X visible the first time, Y the second, Z the third.

That means you could just count which click we're on, and act accordingly:

local clickCount = 1
function click()
	if clickCount == 1 then
		X.Visible = true
	elseif clickCount == 2 then
		Y.Visible = true
	elseif clickCount == 3 then
		Z.Visible = true
	end
	clickCount = clickCount + 1
end

We could also interpret this as,

  • if X is not visible,
    • make X visible
  • otherwise
    • if Y is not visible
      • make Y visible
    • otherwise
      • if Z is not visible
        • make Z visible

This would eliminate the clickCount and also make it react to something hiding the frames / make this easier to "reuse"

function click()
	if not x.Visible then
		x.Visible = true
	else
		if not y.Visible then
			y.Visible = true
		else
			if not z.Visible then
				z.Visible = true
			end
		end
	end
end

We can shorten this using elseif of course:

function click()
	if not x.Visible then
		x.Visible = true
	elseif not y.Visible then
		y.Visible = true
	elseif not z.Visible then
		z.Visible = true
	end
end

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