Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Time wait before closing a Gui?(ANSWERED!)

So I have a play button that pops up when u join and when u click it it goes away. Below is the script...

-- Local Script inside the button

script.Parent.MouseButton1Down:connect(function()
    p = game.Players.LocalPlayer
    p.PlayerGui.ExampleGui:Destroy()
end)

Now I'm needing a time wait mabey like 5 seconds before they are able to close. Why? Because I want them to make sure they read rules so they know what the game is about :)

1 answer

✓ Accepted answer
-- Local Script inside the button
local clicked = false

script.Parent.MouseButton1Down:connect(function()
	if clicked == false then
		clicked = true
	    local timer = 5 -- timer is 5 seconds
	    local p = game.Players.LocalPlayer
	    while timer > 0 do -- while the timer is bigger than 0 subtract 1, every second
	        wait(1)
	        timer = timer - 1
	        p.PlayerGui.IntroGui.ShopFrame.Close.Text = "Cooldown ("..timer..")" -- changing the text of the button to the cooldown, and indicates the seconds remaining till the gui is removed
	    end
	    p.PlayerGui.IntroGui:Destroy()
	end
end)

Hope this helps!

8 comments

0

Do I keep the script that I gave you in a local script still and make a new local script and just add in this script?

0

No, just change the script you already had, copy this and paste it into it.

0

I did and when I click the play button, it goes away right when I press it.

0

Oh I miss read!!! Sorry, I dont understand..

0

Sorry I made two mistakes, but I fixed them. I updated the script, I made a debounce so it does not glitch, and I fixed line 12. Sorry about that

0

Sorry to say but, do you have skype? I'm asking because it is not working and I need help!!

0

Just party me on roblox..

0

I am but you dont answer

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