Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i get a script to detect if a number is lower than 15?

ex

if game.Players.LocalPlayer.Character.HumanoidRootPart.Position - Part.Position.magnitude == 15 then print("hi") end

basically that but if the mag is 15 or lower

1 comment

0

use "<=" instead of "=="

2 answers

✓ Accepted answer

The < operator "less than" let's you do that. You can additionally combine it with =, giving you <= "less than or equal to".

local plr = game.Players.LocalPlayer
local hrp = plr.Character.HumanoidRootPart

if (hrp.Position - Part.Position).magnitude <= 15 then
	print("hi")
end

Make it on ()

Example:

local Part = workspace.Part_ok

if (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - Part.Position).magnitude == 15 then
	print("Hi!")
end

1 comment

1

That is saying it has to be exactly 15 i need it to be 15 or less

This discussion is preserved as it was. New answers, comments, and votes are closed.