Can somebody help me? I've been attempting to do this but it wont work. So I want a script so if you say "heal/", it will heal you, but if you say it too much it will cooldown. Does anyone know how to do that to prevent spam?
Sorry, this site isn't for requesting scripts to be made for you.
Never request scripts, by the way I am nice today: You can make a timer that start after the player chatted "heal/" like this:
local timer = 10 -- At how many seconds the timer will start local timerStarted = false -- Has the time started? function heal() -- Your heal code, inside it put this startTimer() end function startTimer() timerStarted = true while timer > 0 do timer = timer - 1 wait(1) -- Wait 1 second before decrease the timer again, IT WILL NOT FINISH THE FUNCTION UNTIL THE LOOP HAS FINISHED! end timerStarted = false timer = 10 -- Resetting the timer, because the loop has finished end
Ok we added something that checks if the timer Started or not, now we need to modify this:
function heal() -- Your heal code startTimer() end
Into this
function heal() if timerStarted then stopSpam() else -- Your heal code startTimer() end end
This simply check if the player healed while the timer has started or not, but we need to add the last and missing function: the stopSpam().... OOH it's sooooo hard! No joke:
function stopSpam() -- What will the game do to the player? Send a message? Create a gui? Or just banning him? print("A player used the 'heal/' command while his timer started!") -- Simply print to the output the error I wrote end
The last thing is: you need to make sure that you call "heal()" inside the command function/script, example IN METALANGUAGE!:
if player chatted "heal/" then call stopSpam -- or just "stopSpam()" end
It should work, the code hasn't been tested, PM me if you encounter any problem!