HI DEVS,
today were learning about tick but first lets start with a nice meme to make to get them spirits up
Danial
: wait()
the cooler Danial
: tick()
hopefully thta made you smile and got your spirits up
ok lets start
tick()
tick() can be used for many things such as cooldowns
, timers
etc.
so what is tick(), tick() is the time from get ready for this 1st January, 1970, midnight to now in seconds this time is called the Unix Time Epoch.also you can save tick() if you put it in a variable
local savedTick = tick()-- saves how many seconds from now and the Unix Time Epoch from the time this variable is run
putting tick() like this
while wait() do
print(tick())
end
will constantly change as time from and the Unix Time Epoch is constantly changing. you can minus savedTick
from the non saved tick() to get the difference from the time when the variable
was run(when the game was run) from now
local savedTick = tick()
if savedTick - tick() == 10 then
print("10 seconds passed when the savedTick variable ran")
end
lets put knowledge into action
were going to make bomb yay… ok lets start first were going to make the variables were also going to put this in a function so you can start the timer when you want maybe by proximity prompt
local function bombMaker(position)-- the *position* parameter is for the position on where we put our explosion
local timeActivated = tick()-- saves time when the function was called
end
now lets make an if statement to check the time now from when the function was called
local function bombMaker(part)
local timeActivated = tick()
if tick() - timeActivated>=10 then-- you can change the number of time you want the part (bomb) explode
end
end
now lets make the part explode
local function bombMaker(position)
local timeActivated = tick()
if tick() - timeActivated >=10 then
local Explosion = instance.new("Explosion", workspace)-- create explosion
Explosion.Position = position-- we use the position parameter to position our Explosion
end
end
and thats it thats all hope you learned some thing new plz give feed back