How do you create a global wait time for a GUI after clicking?

Recently I have been working on a wait timer that when clicked, will prompt you with a message saying “Thank you for your report, it will be read over.” and they cannot click it until the timer is up. The only problem that I am having is that the when the player resets/loads/rejoins the timer instantly resets and the player can send again. Any and all help is appreciated so thank you in advance :smile:

Code:

This is on a local script by the way.

local waitactivated
local players = game:GetService("Players")
local player = players.LocalPlayer

script.Parent.Call.MouseButton1Click:Connect(function()
	local waitmessage = script.Parent.WaitTimeAfterCall
	waitmessage.Visible = true
	local reason = script.Parent.Reason
	reason.Visible = false
	waitactivated = true
	wait(600)
	waitmessage.Visible = false
	reason.Visible = true
	waitactivated = false
end)

You should use the Lua inbuild os library + datastore to better save the time where you used it when the player joins again

Assuming that this script is a descendant of a ScreenGui, you should make sure the ScreenGui’s ResetOnSpawn Property is set to false.

1 Like

The os library only serves to provide information regarding the system time. I don’t see how it could be used effectively in the code above.

Thank you for this but do you know how to do the same thing when the player leaves and rejoins?

Let’s say you activate this feature at 1pm and then after 10 minutes you can use this feature again, you still have to save it if you leave the game. And for that you just use the os library

I think this should fine (30 char)

Ah, your edit made it more clear. But yes, @NackerExostylx, using DataStoreService (and the os.time() method) could help you achieve persistence between different sessions.

2 Likes

Yeah, as:
You could also save the seconds that are left before you can use the feature again would be an option, but if you want to work correctly with time you should use the os library. This is useful when creating a login awarding system and much more. With the os library you can work decently with time, easily said.

Hope you understand why @NackerExostylx

1 Like

Yes, thank you my friend for this, I will be researching a bit on the os library and watching some tutorials.

1 Like

If so, then I have some videos that might be interesting:

Thank you for these tutorials, I’ll make sure to watch them.

2 Likes