Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
danglt 185
5 years ago

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

0
use "<=" instead of "==" abnotaddable 920 — 5y

2 answers

Log in to vote
5
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

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

Ad
Log in to vote
-5
Answered by
Diltz_3 75
5 years ago

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
That is saying it has to be exactly 15 i need it to be 15 or less danglt 185 — 5y

Answer this question