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 fix a frame going visible randomly?

I am having a problem with a frame changing visibility randomly. For making a game Menu, I want the frame to be invisible when the game launches.

I have done some testing and realized that when I close the game with the frame open(visible), it appears invisible(how it's supposed to be) and if I close the game with the frame closed(invisible), it appears visible at the start of the game.

local Button = script.Parent
local Frame = script.Parent.Parent.Frame

Frame.Visible = false

function onClick()
	if Frame.Visible == true then
		Frame.Visible = false
	elseif Frame.Visible == false then
		Frame.Visible = true
	end
end
Button.MouseButton1Click:Connect(onClick)
while true do
	onClick()
end

I have no idea how to fix this, and it's bothering me very much. If you have a solution, I would be grateful if you would share it with me, thanks in advance.

1 comment

0

Idk what do you mean, but instead of if Frame.Visible == blabalba use Frame.Visible = not Frame.Visible

1 answer

✓ Accepted answer

I don't think you need lines 14 -16. That loop would be flicking it on and off instantly.

2 comments

0

That is correct, plus, he didn't add a wait inside of the while loop which will just crash his game.

0

It works now, thanks.

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