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

How do I have a script look for anything except for a certain range of numbers?

Okay so the title may be a bit confusing but here's some more context

I want this script to detect if the character is in the air and to do that I tried to have the code look for any velocity value that's not near zero (which is where the value varies when you're on the ground)

I used a number range of -1 to 1 for the y velocity when you're on the ground. I need to have the code detect if the y velocity of the humanoidrootpart leaves this range.

if char.HumanoidRootPart.Velocity.y~=NumberRange.new(-1,1) then
	print("you are in the air") --filler code

Apparently this doesn't work and I tried to look in the wiki for any solution

2 comments

0

Vector3.y is deprecated, use Vector3.Y. In other words, use Velocity.Y and not Velocity.y. There are also events of the Humanoid that might help. http://robloxdev.com/api-reference/class/Humanoid

0

robloxdev.com/api-reference/event/humanoid/freefalling

1 answer

if not char.HumanoidRootPart.Velocity.Y > 1 and not char.HumanoidRootPart.Velocity.Y < -1 then
--[[ this makes sure the character is alyays moving in the y i dont know what this is useful for if you don't want them moving delete the NOT on both ]]
end

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