I've been trying to figure out how to detect a player's proximity to a block, for purposes of radiation in a Fallout-esque game I've been making. I cannot think of how I would get the script to detect if the player is within the, say, 10-stud area around the block so the player gathers Radiation (of which I have being kept track of with an IntValue inside the character).
Use Player:DistanceFromCharacter. It accepts a Vector3 position.
For example, if you want to get the distance between the player and a block:
local block = game.Workspace.RadiationPart local distance = player:DistanceFromCharacter(block.Position)
Note that it returns 0 if the player's character does not exist.
Another way to do this is using .magnitude (which can be used for any object instead of just the player)
local block = game.Workspace.RadiationPart local distance = (player.Character.Torso.Position - block.Position).magnitude