How to make a range of distance with a value without touching a part?

Well, I want to make a range of distance that if the player is within range, he can do the rest of the script’s function and that the range number is a value of a NumberValue. I really don’t know how to do this…

2 Likes

Use the magnitude between two objects

You could use the method “DistanceFromCharacter” on the Player .
For example :

local Part = workspace.Part
local Range = PathToNumberValue
local Distance = Player:DistanceFromCharacter(Part.Position) -- Returns the Distance this is equal to (Player.Character.PrimaryPart.Position-Part.Position).Magnitude

if Distance <= Range.Value then
 print("Player is in range")
end
1 Like