I made a jail that is made to punish the player that try to go out of the jail by loop killing them using distance. I think it prevent pretty well exploiters to go out and kill player with anti tp exploits too. I make the script free to use for everyone.
local JailBannedUsers = {"MagicLuau"}
local DistanceCalled = {}
local function UnbanPlayer(player:Player)
if table.find(JailBannedUsers,player.Name) then
table.remove(JailBannedUsers,table.find(JailBannedUsers,player.Name))
end
player.Character.Humanoid.Health = 0
DistanceCalled[player.UserId] = nil
end
game:GetService("ServerStorage").BindableEvents.UnJailBanPlayer.Event:Connect(function(player)
if not player:IsA("Player") then
return
end
UnbanPlayer(player)
end)
while wait() do
local sucess,errorm = pcall(function()
for _, player in game.Players:GetPlayers() do
if table.find(JailBannedUsers,player.Name) then
local distancebymagnitude = (player.Character.HumanoidRootPart.Position - game.Workspace.Jail.Bottom.Position).Magnitude
if distancebymagnitude > 10 then
if DistanceCalled[player.UserId] then
if tick() - DistanceCalled[player.UserId] < 1 then
-- Kill player
player.Character.Humanoid.Health = 0
DistanceCalled[player.UserId] = tick()
else
DistanceCalled[player.UserId] = tick()
end
end
if not DistanceCalled[player.UserId] then
DistanceCalled[player.UserId] = tick()
end
player.Character.HumanoidRootPart.CFrame = game.Workspace.Jail.Bottom.CFrame + Vector3.new(0,2,0)
task.wait(0.2)
local distance = (player.Character.HumanoidRootPart.Position - game.Workspace.Jail.Bottom.Position).Magnitude
if distance > 10 then
player.Character.Humanoid.Health = 0
end
end
if distancebymagnitude > 5 then
--player.Character.HumanoidRootPart.Anchored = true
task.spawn(function()
local success,errror = pcall(function()
game.MarketplaceService:PromptProductPurchase(player,3144561327)
end)
end)
player.Character.HumanoidRootPart.CFrame = game.Workspace.Jail.Bottom.CFrame + Vector3.new(0,2,0)
end
end
end
end)
end
What do you think of it? What could i improve?