How can i make GUI button appear after 8 seconds?

Hey Devs,

So i made GUI on/off music button using this script: `local music = game.Workspace.Sound.BGM
local button = script.Parent
playing = true

script.Parent.MouseButton1Click:Connect(function()
if playing == true then
music.Playing = false
button.Text = “:mute:
playing = false
else
music.Playing = true
button.Text = “:loud_sound:
playing = true
end
end)`

But the problem is i also have intro in my game, and the button is kinda annoying because its over laying.

I also took picture so you can better understand what i mean.

How can i make the button appear after like 5 seconds? Or 8? Basically after some time.

I will be thankful for any comments!

Have a great day,
-jeziskrista

2 Likes

use ``` for code block

local music = game.Workspace.Sound.BGM
local button = script.Parent
playing = true

script.Parent.MouseButton1Click:Connect(function()
    if playing == true then
        music.Playing = false
        button.Text = “:mute:”
        playing = false
    else
        music.Playing = true
        button.Text = “:loud_sound:”
        playing = true
    end
end)

-- add the followings
button.Visible = false
task.wait(8)
button.Visible = true
2 Likes

Thank you! I will try it out, and follow up with update.

Also thanks for correcting me, i didn’t noticed that thr code block wasnt visible.

I’m not fully sure I am doing this right, but the button is visible, and when pressed its gone for 8 seconds and then show up again.

Am i using the script wrong?

Did put the .Visible = false in the MouseButton1Click event?

1 Like

Also, another thing: If you handle other stuff in your script and you don’t want your entire script to be stopped for 8 seconds (because that what’s happening as of right now), maybe use task.delay? You can read more about it here: task | Documentation - Roblox Creator Hub

1 Like

This is simple … have the Gui button start as Visible = false
Then just make it visible …

task.wait(8)
button.Visible = true

3 Likes

Might seems simple for you, but for me as a rookie not. I’m still doing something wrong… I think I’m putting the script wrongly.

Could you try reviewing the script and including the part with 8 seconds for me please?

1 Like

There is a way to make GUIs have priority and appear some other UI elements aslong as they’re covering them up.

1 Like

You’ll have to make a local script for that to work as the server doesn’t have access to the PlayerGUI.
I’d just recommend disabling the button gui, and set it as enabled at the end of the function playing the intro if that’s how you want to go with it.

2 Likes

Yeah, that’s basically how i want to do it. But I’m still a rookie and have no idea from your words how to do it… Still thanks for the reply!

1 Like

Technically, all you have to do is put those lines of code once the intro is done playing;

local plr = game:GetService("Players").LocalPlayer
local plrGUI = plr:GetService("PlayerGui")
local button = plrGUI.button --Or just add the name of the button's gui

button.Enabled = true

2 Likes

Thanks! Let me try it really quickly

1 Like

Should i put it into the Intro script or the Button script?

1 Like
script.Parent.Visible = false
task.delay(8, function()
	script.Parent.Visible = true
end)
script.Parent.MouseButton1Click:Connect(function()
	if playing == true then
		music.Playing = false
		button.Text = “:mute:”
		playing = false
	else
		music.Playing = true
		button.Text = “:loud_sound:”
		playing = true
	end
end)

This would make it invisible, and schedule a function to happen 8 seconds later, making the button visible Is this what you want, or did i not understand the task correctly?

2 Likes

No this is simple … In your script I don’t even see a call for .Visible or not .Visible. That would be how you do that. Don’t let the problem overwhelm you was my point.

2 Likes

You should put it into the intro script

2 Likes

I’m the most stupid person ever, but I’m still doing something wrong… Thanks for your effort, but could you possibly give me whole script? (The script i already used with that additional part which make it gone for 8 seconds included in it.)

I would be thankful for that.

I’m again sorry, but i have no idea what I’m still doing wrong…

Can you send the intro script?

1 Like

Well, just implement the

script.Parent.Visible = false
task.delay(8, function()
	script.Parent.Visible = true
end)

In your script, maybe make it above the MouseButton1Click event, also I would recomend learning more about task.delay: task | Documentation - Roblox Creator Hub

1 Like