Sign in to follow this  
Milllk

how can i set cooldown for invoking a function

Recommended Posts

Milllk    59

how can i set cooldown for invoking a function 

 

like this,i have a function here

 

local somefuc()

 

local creature = SpawnPrefab("prefab"...

 

doTaskIntime("creature",10)

 

end

 

how can i set the player only can invoke once during 10 sec?

 

is there any time function i can use?

 

 

Share this post


Link to post
Share on other sites
ZupaleX    270

You can make a use of GetTime() and store the last invoke time as well, so when the player try to invoke, it would perform a check like 

if GetTime() - lastinvoketime < 10 then   returnelse   DoYourStuffsend

Share this post


Link to post
Share on other sites
Milllk    59

 

You can make a use of GetTime() and store the last invoke time as well, so when the player try to invoke, it would perform a check like 

if GetTime() - lastinvoketime < 10 then   returnelse   DoYourStuffsend

thank you a lot ,ill try it out

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this