You’re passing in a string to a function which isn’t right and your function IsThePlyArrested is wrong because you don’t need a ) at the end of it
Also plypos is global which it doesn’t need to be, same with the function
What you would want to do is make it so the timer is created when the player is arrested like this
Also you don’t want the timer to run forever, you only need it to run for the duration of their arrested time. Once they are un-arrested you can remove the timer
---------------- Config ----------------
local pos1 = Vector( -1416, 142, -131)
local pos2 = Vector( -1371, 53, -56)
---------------- Config ----------------
local function IsThePlyArrested( arrestedply, time, actor)
timer.Create( "playerinbounds"..ply:EntIndex(), 1, time, function()
if !IsValid(arrestedply) then return end
local plypos = arrestedply:GetPos()
if arrestedply:IsPlayer() and plypos:WithinAABox( pos1, pos2 ) then
arrestedply:unArrest()
timer.Remove("playerinbounds"..ply:EntIndex())
end
end)
end
hook.Add("playerArrested", "isplayerarrested" , IsThePlyArrested)
An easier (and more efficient) option to do all of this is to make an entity that uses
ENT:StartTouch
You make the entity not draw / invisible and so players can pass through it but so it still calls StartTouch
You would just place the entity in a doorway or something / where ever you would consider them escaping and then when they hit it, unarrest them and set them back to where they were like this
function ENT:StartTouch(ent)
if ent:IsPlayer() and ent:isArrested() then
local playerPos = ent:GetPos()
ent:unArrest()
timer.Simple(.05,function()
ent:SetPos(playerPos)
end)
end
end