Frame Visibility Issue

I’m trying to make a frame open within 5 seconds of the player loading in. I’m trying to make another frame pop up at 10 seconds of the player in the game. I’m trying to make it so that whenever the 10 second frame opens, the 5 second frame closes if its open. Here’s the code im using. Any help would be amazing!

local frame = script.Parent.Parent.RandomFrame2

wait(5)
script.Parent.Visible = true

if frame.Visible == true then
	script.Parent.Visible = false
end
1 Like

I think you could do:

frame.Visible = false
wait(5)
frame.Visible = true
if frame2.Visible = true then-- you could make the frame visible in a different script frame2 is the other gui
frame.Visible = false
end

You’re checking if frame.Visible is true right away, regardless of if ten seconds has passed yet or not. I assume you’re making frame visible in another script. This isn’t really ideal but it will probably make this a whole lot easier, so try the following instead:

Also would recommend making wait(5) into task.wait(5)

local frame = script.Parent.Parent.RandomFrame2

wait(5)
script.Parent.Visible = true
wait(5)
frame.Visible = true 
script.Parent.Visible = false

So instead of using a script in different frames, I merge them into one?

Im stupid,yeah thats a much better way, im tired lol

You can use one local script just get the frames and then you can basicly copy and paste his code.

1 Like

Well, it would make what you’re doing here a whole lot easier and personally I prefer everything in one centralized place for general UI stuff. Alternatively you could use separate scripts and instead check whenever frame's visibility is set differently and fire the scripts event to go off then, but honestly that’s a lot more work and kinda useless when it’s much easier to keep it in one place.

Got it. Yeah, it worked. Thanks so much!

1 Like