Keeping players in jail after attempt to rejoin

Hi everyone,

I am creating an arrest tool for my city project, but I need to know if there is a simple function in a script to teleport a player back into the ‘Incarcerated’ team after they rejoin the server during their jail time. I am asking for this because rejoining the server is a common way to break out of jail. Thanks!

I only know a way for it to save in a single server which would be store a table of in-jail players, when they leave, their timer stops. You could probably datstore this and get a system game-wide.

How could I do that?

Store a simple table, like local jailed = {}, use table.insert and table.remove , as well as datastores.

I know the tables but I’m not fully sure on how to fully code it.

Is this good? (Random text)

local players = game:GetService("Players")
local jailed = {}

--Jail function
local function jailPlayer(player)
	player.TeamColor ="Bright violet")

--Jail player
jailed[player.Name] = true

--Unjail player
jailed[player.Name] = nil

--Check if player jailed when entering the game
	if jailed[player.Name] then


Do you want this to only work if they join the same server or if they join any server?

Any server )random text)

You will need to use a datastore.

Okie (random text) loll

Do you know how to do that?

No oof (random text)

Your going to want to use the StarterGUI for local scripts, SSS for your main scripts and the ReplicatedStorage to store everything in.

I feel I’m right, tell me if not :joy:

Pretty sure your correct but I don’t know what in the world to type

So basically, I need to go to bed, but I will try to get a script tomorrow.

But essentially what you need to do, is when a function is called, add the players User Id to a database, then when they join they will be tested to see if they are in that database & if so, they are teleported to inside a prision.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.