The situation- I have a command that should only display help for itself if the player does certain things… actually, just read it below.
--I have this script because the following command (not the original) only does what it should under certain conditions defined by the player, --so if the player doesn't know why the command isn't working how they want (because they are not defining the correct conditions), then the command --will suggest what to do with HELPFUL TEXT to help them do what they wanted. I decided to try using a timer because I only want the --HELPFUL TEXT to show if the player has spammed the command in annoyance wondering why it doesn't work as they expect it to, but I don't want --the command to show the HELPFUL TEXT if the player has already seen the text 2 times, as they should know what to do by now. local annoycheck 0 -- The var defining how many times this command has been called concommand.Add( "timer_test_command", function( ply ) if annoycheck < 2 then --Checks that the function hasn't been called over 2 times if ( timer.Exists( "GravityDropAnnoyTimer" ) ) then --Not sure if timers destroy themselves when done, they probably do annoycheck = annoycheck + 1 --Add 1 to how many times the function has been called local annoyleft = timer.TimeLeft( "GravityDropAnnoyTimer" ) --Checks that the previous timer has not ended if annoyleft >= 0.01 then --If the timer has still got time remaining on it, then send over a helpful message. ply:SendLua( [[chat.AddText(Color(255,255,100), "HELPFUL TEXT")]] ) end else timer.Create( "GravityDropAnnoyTimer", 1, 0, function() end ) --This timer is definitely the issue here, I want it to run in the background instead of running a function or something end else if ( timer.Exists( "GravityDropAnnoyTimer" ) ) then --I'm probably screwing a lot of stuff up with this, but if the function has been called over 100 times, I don't want the helpful text to be sent. timer.Destroy( "GravityDropAnnoyTimer" ) end end end)
So, I’m 99% sure I used the timer completely wrong, as I don’t want it to do anything, just check itself whenever the command is run again. I think the solution is probably really simple or easy, because timers are new for me.