Time based kicking

Hello I am interested in how you would kick the player from the server if its a certain time!

I know this has something to do with tick but I’m still wondering how I would do that, if anybody has a brief explanation then that would be great. :slight_smile:

Thanks!

I need to understand the question better. Is it a certain in-game time, or time outside of the game? Or is it a timer of some sort? I’ll just make one of each.

--In game time
local kickTime = 200 --whatever time
local currentTime = workspace.timeValue --whatever time value you have
local playerToKick = --the player
while wait() do
     if currentTime == kickTime then
             playerToKick:kick("Time reached")
     end
     break --end loop
end
--global time
local t = {
y = Year,
m = Month,
d = Day,
h = Hour,
m = Minute,
s = Second} --set everything to the desired time
local playerToKick = --the player
while wait() do
    if t == os.time () then --the current time
    playerToKick:kick("Time reached")
    break
    end
end

In a nutshell, os.time() is a function that returns the time in the timezone of the server. if used on client, it returns the client’s local system time.
While comparing your time to os.time, keep in mind that it returns a table, so you can compare specific elements of it, from the year, all the way down to the second.

Thanks, for the examples! Helps a lot. :slight_smile: