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.
local players = game:GetService("Players")
local jailed = {}
--Jail function
local function jailPlayer(player)
player.TeamColor = BrickColor.new("Bright violet")
player:LoadCharacter()
end
--Jail player
jailed[player.Name] = true
jailPlayer(player)
--Unjail player
jailed[player.Name] = nil
--Check if player jailed when entering the game
players.PlayerAdded:Connect(function(player)
if jailed[player.Name] then
jailPlayer(player)
end
end)
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.