How can I detect how much radius is between a part and the player?

So I have a part it can detect when you click on it without a click detector and I want to make like a max activate distance for it how can I achieve this this is my code

	for i, objects in pairs(mouse.Target:GetChildren()) do
		if objects:IsA("BoolValue") and objects.Name == "Inspectable" and objects.Value == true then
			if player.Character.HumanoidRootPart.Position.Magnitude < objects.Parent.Position.Magnitude - 10 then
			print(objects.Parent.Name)
			im.inspect()
			end
		end
	end

I don’t know how to edit the magnitude where I can make it like a max click distance

it works well but I want to shorten the distance even more

if (player.Character.HumanoidRootPart.Position - objects.Parent.Position).Magnitude < maxDistance then
...run the button code
end
1 Like

no the problem is I am not using a click detector because what I am attempting cant use a click detector so I want to kinda make its own max activation distance without it being a click detector by comparing the players humanoid root part magnitude and the parts magnitude and then telling if its in distance.

ahhh thanks this works I dont know why I didnt think of this but this worked like a charm!

1 Like

ah, sorry the title and what you are trying to achieve, don’t really correlate
shouldn’t it be titled “Getting the Distance Between a part and the player?”

well I guess I could title it that way but then someone would respond and give me some print using basic magnitude when I was trying to subtract the magnitude from the players magnitude and the parts magnitude and seeing how far away they are