local RADIUS = 45 -- Change it according to what you want
local function CheckRadius(p1, p2) -- Player instances
if p1:IsA("Player") and p2:IsA("Player") then
local char_1 = p1.Character
local char_2 = p2.Character
if char_1 and char_2 then
if char_1.PrimaryPart and char_2.PrimaryPart then
if (char_1.PrimaryPart.Position - char_2.PrimaryPart.Position).magnitude <= RADIUS then -- Checking magnitude between p1 and p2
return true -- Yes, they're within given radius!
else
return false -- Nope, they aren't!
end
end
end
end
return nil
end
local p1 = game.Players.Avanthyst
local p2 = game.Players.PLAYER
local success = CheckRadius(p1, p2)
if success then
print("Yup!")
end