Wait x seconds in lua client script GARRYSMOD

Hello, i wonder how i can wait in a lua garrysmod client script.

Example
#SHOWTEXT
WAIT 5 SECONDS
#SHOWANOTHER TEXT

How is that possible?

Look into timer.Simple or timer.Create, I think

Yes that’s on the server side… But on the client side ?

Timers can be used serverside and clientside.

How is that possible? My timers i created are not in the IF (SERVER) statement or IF (CLIENT) …
So you can put the timer in the client statement?
Any examples plz :slight_smile:

[Lua]
timer.Simple( 20, function()
– Runs after 20 seconds
end )

timer.Create( “Name”, 5, 0, function()
– Runs every 5 seconds
end )

timer.Destroy( “Name” ) – Destroys the timer called Name
[/lua]

These can be either serverside or clientside.

[lua]
function ShowTextCountdown(msg1, msg2, delay, times)
print(tostring(msg1))
timer.Create(“ShowTextCountdown”, tonumber(delay), tonumber(times) or 1, function()
print(tostring(msg2))
end)
end
[/lua]

Would do the same thing both clientside and serverside. You would then do something like this:
[lua]
ShowTextCountdown(“please wait a few seconds”, “thx for waiting a few seconds”, 5, 1)
– This would first print “please wait a few seconds”, then 5 seconds later print “thx for waiting a few seconds” (The 1 at the end is optional, it will specify how many times the timer will be ran.
[/lua]