Jailed = {"Player"}
Jail = game.Workspace.JailBrick
function CheckJail (player)
for _, p in pairs (Jailed) do
if player.Name == p then
return true
end
end
return false
end
function findPlayer(name)
for _, v in pairs(game.Players:GetPlayers()) do
if string.find(string.lower(v.Name),string.lower(name)) then
return v
end
end
end
game.Players.PlayerAdded:connect(function(player)
print (CheckJail(player))
if CheckJail (player) == true then
player.CharacterAdded:connect(function(Character)
if player and Character and Character:FindFirstChild ("Humanoid") and Character:FindFirstChild ("Humanoid").Health > 1 then
print ("Jailing "..player.Name.."...")
wait ()
Character.Torso.CFrame = CFrame.new(Jail.Position) * CFrame.new(0, 3, 0)
end
end)
end
player.Chatted:connect(function(msg)
msg = msg:lower()
print (player.Name.." Has chatted!")
if msg:sub(1,6) == ";Jail " then
print (player.Name.." Has chatted the command "..msg:sub(1,6))
local vic = findPlayer(msg:sub(7))
if CheckJail(vic) == false then
print ("Jailing "..vic.Name.."...")
if vic and vic.Character and vic.Character:FindFirstChild ("Humanoid") and vic.Character:FindFirstChild ("Humanoid").Health > 1 then
vic.Character.Torso.CFrame = CFrame.new(Jail.Position) * CFrame.new(0, 3, 0)
end
table.insert(Jailed, vic)
end
elseif msg:sub(1,8) == ";Unjail " then
print (player.Name.." Has chatted the command "..msg:sub(1,8))
local vic = findPlayer(msg:sub(7))
if CheckJail(vic) == true then
print ("UnJailing "..vic.Name.."...")
vic:LoadCharacter()
table.remove(Jailed, vic)
end
end
end)
I am making a jail player script for a certain group I am in, but it doesn't seem to be working.
