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

Time wait before closing a Gui?(ANSWERED!)

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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

Log in to vote
1
Answered by 8 years ago
-- 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!

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? FiredDusk 1466 — 8y
0
No, just change the script you already had, copy this and paste it into it. AbsoluteAxiom 175 — 8y
0
I did and when I click the play button, it goes away right when I press it. FiredDusk 1466 — 8y
0
Oh I miss read!!! Sorry, I dont understand.. FiredDusk 1466 — 8y
View all comments (4 more)
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 AbsoluteAxiom 175 — 8y
0
Sorry to say but, do you have skype? I'm asking because it is not working and I need help!! FiredDusk 1466 — 8y
0
Just party me on roblox.. AbsoluteAxiom 175 — 8y
0
I am but you dont answer FiredDusk 1466 — 8y
Ad

Answer this question