✓ Accepted answer
You should probably just check the distance between players instead of having each of their parts have a touched event and if you want it to be similar to jailbreak.
local runService = game:GetService("RunService")
local contextService = game:GetService("ContextActionService")
local ply = game.Players.LocalPlayer
local char = ply.Character
local ui = ply.PlayerGui.TagUi
ply.CharacterAdded:connect(function(c)
char = c
end)
function tweenUi()
end
function searchTarget()
local dis = 3
local tar = nil
for _,v in pairs(game.Players:GetChildren()) do
if v.Character and v.Character ~= char then
local tDis = (v.Character.PrimaryPart.Position-char.PrimaryPart.Position).magnitude
if tDis < dis then
dis = tDis
tar = v
end
end
end
if target then
ui.Enabled = true
target = tar
contextService:BindAction("tagTween",tweenUi,false,Enum.KeyCode.E)
else
ui.Enabled = false
contextService:UnbindAction("tagTween")
end
end
runService:BindToRenderStep("findTarget",0,searchTarget)