Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix a frame going visible randomly?

Asked by
Ghost40Z 118
4 years ago

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.

0
Idk what do you mean, but instead of if Frame.Visible == blabalba use Frame.Visible = not Frame.Visible mixgingengerina10 223 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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

0
That is correct, plus, he didn't add a wait inside of the while loop which will just crash his game. mixgingengerina10 223 — 4y
0
It works now, thanks. Ghost40Z 118 — 4y
Ad

Answer this question