This prisoner script i made does not work, it used to and now is just broken completely, any help?
local Players = game:GetService("Players")
local function PlayerIsInJail(Player)
if Player.Team.Name == "Prisoner" then
return true
end
end
local function uncrime(Player)
Player.Team = game:GetService("Teams").Neutral
print("players team = neutral")
Player:WaitForChild("stats").Arrested = false
print("players arrested value = false")
Player:LoadCharacter()
Player.PlayerGui.PrisonTime:Destroy()
print("players prisontime gui destroyed")
end
local function GetPlayerJailTime(Player)
return Player:WaitForChild("stats"):WaitForChild("JailTime").Value
end
local function HandlePlayer(Player)
local function HandleCharacter(Player, Character)
if PlayerIsInJail(Player) then
while GetPlayerJailTime(Player) > 0 do
wait(1)
Player:WaitForChild("stats"):WaitForChild("JailTime").Value = Player:WaitForChild("stats"):WaitForChild("JailTime").Value - 1
end
else
uncrime(Player)
end
end
if Player.Character then
HandleCharacter(Player, Player.Character)
end
end
for _, Player in pairs(Players:GetPlayers()) do
HandlePlayer(Player)
end
local Players = game:GetService("Players")
local function PlayerIsInJail(Player)
if Player.Team.Name == "Prisoner" then
return true
else
return false
end
end
local function uncrime(Player)
Player.Team = game:GetService("Teams").Neutral
print(Player.Team)
Player:WaitForChild("stats").Arrested.Value = false
print("players arrested value = false")
Player:LoadCharacter()
Player.PlayerGui.PrisonTime:Destroy()
print("players prisontime gui destroyed")
end
local function GetPlayerJailTime(Player)
return Player:WaitForChild("stats"):WaitForChild("JailTime").Value
end
local function HandlePlayer(Player)
local function HandleCharacter(Player, Character)
if PlayerIsInJail(Player) then
while GetPlayerJailTime(Player) > 0 do
wait(1)
Player:WaitForChild("stats"):WaitForChild("JailTime").Value = Player:WaitForChild("stats"):WaitForChild("JailTime").Value - 1
end
else
uncrime(Player)
end
end
if Player.Character then
HandleCharacter(Player, Player.Character)
end
end
for _, Player in pairs(Players:GetPlayers()) do
HandlePlayer(Player)
end
I just updated the script to this, i changed it from a function to just after its done looping, idk if it works tho?
local Players = game:GetService("Players")
local function PlayerIsInJail(Player)
if Player.Team.Name == "Prisoner" then
return true
else
return false
end
end
local function GetPlayerJailTime(Player)
return Player:WaitForChild("stats"):WaitForChild("JailTime").Value
end
local function HandlePlayer(Player)
local function HandleCharacter(Player, Character)
if PlayerIsInJail(Player) then
while GetPlayerJailTime(Player) > 0 do
wait(1)
Player:WaitForChild("stats"):WaitForChild("JailTime").Value = Player:WaitForChild("stats"):WaitForChild("JailTime").Value - 1
end
Player.Team = game:GetService("Teams").Neutral
print(Player.Team)
Player:WaitForChild("stats").Arrested.Value = false
print("players arrested value = false")
Player:LoadCharacter()
Player.PlayerGui.PrisonTime:Destroy()
print("players prisontime gui destroyed")
end
end
if Player.Character then
HandleCharacter(Player, Player.Character)
end
end
for _, Player in pairs(Players:GetPlayers()) do
HandlePlayer(Player)
end