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 = “”
playing = false
else
music.Playing = true
button.Text = “”
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.
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
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
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.
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
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?
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.
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…