How would I do a tempban script?

Hi devs,

even tho there is many posts asking this on the devforum, it is still confusing me a lot. How can I make a tempban script? Help is greatly appreciated! :slight_smile:

3 Likes

I don’t understand tempban, can you explain?

1 Like

tempban means temporary ban

so you would only be banned for a specified time

Ik it means temporary I just didn’t know what he meant by that, thanks anyway

Basically, it’s like a ban, but when a certain amount of time pass, your unbanned. And I don’t know how would I script it.

use os.time() and check if it reached the time to unban

os.time() is read in Unix, so you would need a timetounix converter script

I don’t know how would I do that though. Like, do I do os.time < bannedtime??

Os.time only checks the time in Unix , not globally decreasing the time

So you would need a timetounix script

Make a data store that saves the current os.time and length of the ban. Then each time the player tries to join then find if the current os.time is greater then length of the ban+old os.time then unban and remove datastore.

You’re a genius but i can’t script that since I’m in mobile right now but you should instead os.time+hourgiven

1 Like

So it’s would be like that?


local DDS = game:GetService("DataStoreService"):GetDataStore("Ban")
local current = os.time()

game.Players.PlayerAdded:Connect(function(plr)
if DDS:GetAsync(plr.UserId.."-TEMPBAN",100000,true) then
if current + 1000000 + os.time() then
-- remove
 end
end
1 Like

Can’t tell rn, but it looks like it would work

Would the script above I did work?

Or can you fix the script I did?

Seems like it. Just wait till I get on comp

I still don’t understand… I would really need a example.

I am working on the system for you right now. I will be done in about 5-10 minutes.

1 Like

Thank you so much! :slight_smile: I wish everyone was like you.

1 Like

I guess you could somehow check the Epoch time and if the epoch time is > than the value of when you banned the person then they are no longer banned.

Nearly done. Just need to set up the command or can you do that?

Wait can’t they change their OS’s time? Meaning they can just change their devices time in the settings to get un-temp banned.

2 Likes