function funcNear()
local nearestPlr
for _, val in pairs(game.Players:GetPlayers()) do
local char = val.Character
if char then
local dist = val:DistanceFromCharacter(script.Parent.HumanoidRootPart.Position)
if dist < script.Parent.Configuration.TriggerDistance.Value then
local nearestPlr = char
print(nearestPlr)
end
end
end
return nearestPlr
end
while wait(3) do
local x = funcNear()
print(x)
end
nearestPlr is just returning nil when being called.

3 comments
You have to identify what nearestPlr is.
If no character is closer than
script.Parent.Configuration.TriggerDistance.Value, thennearestPlrwill never be assigned to. Also, if multiple characters are close enough, it will pick the first one it finds, rather than the one which is actually closer.yeah im aware, this was mainly to test returning a value to another modulescript