Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Jury_Morphs = {"JURY"}
- local JuryRemote = game.ReplicatedStorage.eTech.Remotes.JURY
- local JailSpawn = game.Workspace.TeleportParts.Jail
- local ArrestedPlayers = {}
- function getRandomCell()
- local Folder = game.Workspace.JuryTPs:GetChildren()
- local SpawnPart = Folder[math.random(1,#Folder)]
- return SpawnPart
- end
- function removeTools(plr)
- local char = plr.Character
- for i,tool in pairs(char:GetChildren()) do
- if tool:IsA("Tool") then
- tool:Destroy()
- end
- end
- for i,tool in pairs(plr.Backpack:GetChildren()) do
- if tool:IsA("Tool") then
- tool:Destroy()
- end
- end
- end
- local PunishInfo = {
- ["Disobedience"] = {
- ["TIME"] = 240,
- ["INFO"] = "Disobedience and/or refusal to comply."
- },
- ["Harrassment"] = {
- ["TIME"] = 180,
- ["INFO"] = "Harrasment/annoyance towards an Officer."
- },
- ["Tresspassing"] = {
- ["TIME"] = 300,
- ["INFO"] = "Trespassing of unauthorized area."
- },
- ["Defunct"] = {
- ["TIME"] = 400,
- ["INFO"] = "Defunct and unauthorized behavior."
- }
- }
- game.Players.PlayerAdded:Connect(function(plr)
- local ArrestedValue = Instance.new("BoolValue",plr)
- ArrestedValue.Name = 'Arrested'
- local plrHasBeenChecked = false
- plr.CharacterAdded:Connect(function(Char)
- repeat wait() until Char.Parent == workspace
- print('parent = workspace')
- local TableCheck = false
- if ArrestedPlayers[plr.Name] then
- TableCheck = true
- end
- if TableCheck == true and ArrestedPlayers[plr.Name] ~= 0 then
- if ArrestedPlayers[plr.Name] > 0 then
- if plrHasBeenChecked == false then
- plrHasBeenChecked = true
- ArrestedValue.Value = true
- end
- if plr["Arrested"] then
- if plr["Arrested"].Value == true then
- print('Found '..plr.Name.."'s Table.")
- local TimeLeft = ArrestedPlayers[plr.Name]
- local SpawnPart = getRandomCell()
- Char:WaitForChild("HumanoidRootPart").CFrame = SpawnPart.CFrame + Vector3.new(0,3,0)
- print('Teleported Player back to jail')
- removeTools(plr)
- JuryRemote:FireClient(plr,"Disable")
- local RankTag = Char.Head:WaitForChild("Rank"):WaitForChild("Frame").Rank
- local plrIsInServer = true
- game.Players.PlayerRemoving:Connect(function(PLAYER)
- if PLAYER == plr then
- plrIsInServer = false
- end
- end)
- if plr["Arrested"] then
- repeat wait(1)
- TimeLeft = TimeLeft - 1
- RankTag.Text = TimeLeft
- ArrestedPlayers[plr.Name] = TimeLeft
- until TimeLeft == 0 or plrIsInServer == false or ArrestedValue.Value == false
- if TimeLeft == 0 or plr["Arrested"].Value == false then
- table.remove(ArrestedPlayers,ArrestedPlayers[plr.Name])
- print('Removed Table')
- JuryRemote:FireClient(plr,"Enable")
- ArrestedValue.Value = false
- plr:LoadCharacter()
- end
- if plrIsInServer == false then
- print('Player Left, Stopping')
- end
- end
- end
- end
- end
- elseif TableCheck == false then
- print('player not checked, not in jail')
- plrHasBeenChecked = true
- end
- end)
- end)
- JuryRemote.OnServerEvent:Connect(function(Player,Punishment,TargetPlayer)
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local isJury = false
- for i,v in pairs(Jury_Morphs) do
- if Player.Character.MorphName.Value == v then
- isJury = true
- end
- end
- if isJury == true then
- local PunishmentTime = PunishInfo[Punishment]["TIME"]
- local TimeLeft = PunishmentTime
- local TargetCharacter = TargetPlayer.Character
- local ArrestedValue = TargetPlayer:WaitForChild("Arrested")
- ArrestedValue.Value = true
- local SpawnPart = getRandomCell()
- TargetCharacter:WaitForChild("HumanoidRootPart").CFrame = SpawnPart.CFrame + Vector3.new(0,3,0)
- removeTools(TargetPlayer)
- JuryRemote:FireClient(TargetPlayer,"Disable")
- local tableFound = false
- local PlayerName = TargetPlayer.Name
- for _, thing in pairs(ArrestedPlayers) do
- if thing == ArrestedPlayers.PlayerName then
- print('Table found not making a new one')
- tableFound = true
- end
- end
- if tableFound == false then
- local newTable = {
- [TargetPlayer.Name] = PunishmentTime
- }
- table.insert(ArrestedPlayers,newTable)
- print('Table was not found, making a new one')
- end
- ArrestedPlayers[TargetPlayer.Name] = PunishmentTime
- local RankTag = TargetPlayer.Character.Head:WaitForChild("Rank"):WaitForChild("Frame").Rank
- local plrIsInServer = true
- game.Players.PlayerRemoving:Connect(function(PLAYER)
- if PLAYER == TargetPlayer then
- plrIsInServer = false
- end
- end)
- repeat wait(1)
- TimeLeft = TimeLeft - 1
- RankTag.Text = TimeLeft
- ArrestedPlayers[TargetPlayer.Name] = TimeLeft
- until TimeLeft == 0 or plrIsInServer == false or ArrestedValue.Value == false
- if plrIsInServer == false then
- print('Player Left, Stopping')
- end
- if TimeLeft == 0 or ArrestedValue.Value == false then
- table.remove(ArrestedPlayers,ArrestedPlayers[TargetPlayer.Name])
- print('removed table')
- TargetPlayer:LoadCharacter()
- JuryRemote:FireClient(TargetPlayer,"Enable")
- ArrestedValue.Value = false
- end
- end
- end)
- game.ReplicatedStorage.eTech.Remotes.ArrestRelease.OnServerEvent:Connect(function(plr,TargetPlayer)
- local ArrestValue = TargetPlayer:FindFirstChild("Arrested")
- local PlayerName = TargetPlayer.Name
- if ArrestValue then
- local playerTable = ArrestedPlayers[TargetPlayer.Name]
- if playerTable then
- ArrestValue.Value = false
- table.remove(ArrestedPlayers,ArrestedPlayers.PlayerName)
- print('Releasing Player')
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement