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 make a code saying 1 or higher because im trying to make an attributes thing?

local atrib = game.StarterGUI.PlayGUI.Frame.Attributes.Frame.Attribute.TextButton this isn't the whole script but bits of it if attrib.Text == 1 and then i don't know how to say 1 and higher in code and one more thing how do i change the color of a frame or text button

2 answers

✓ Accepted answer

Not sure why you accepted the other answer even though it didn't answer your question.

To check whether a variable is higher than or equal to 1 you use >= and to turn a string into a number you use tonumber()

In the if statement I use tonumber(attrib.Text) twice; first, to make sure it is actually a number then the second, compares it only when it's a number.

local attrib = {Text = "5"}

local function CheckNumber()
	if tonumber(attrib.Text) and tonumber(attrib.Text) >= 1 then
		print("Yes, it is 1 or greater.")
	else
		print("No, it is less than 1 or not a number")
	end
end


CheckNumber()

attrib.Text = "0"
CheckNumber()

attrib.Text = "GSFDgs4545"
CheckNumber()

Read more about:

tonumber()

Relational Operators

1 comment

1

thx

The difference between a StringValue and a NumberValue is that, a StringValue's value can be set to a text such as "Hello". While, a NumberValue's value can only be set to numbers.

5 comments

0

do u know how to make the camera follow an animation

0

Checkout the Cutsecen Editor by CloneTrooper1019. Also, accept the answer if it helped!

0

make the HumanoidRootPart the CameraSubject and vice versa

0

^^

0

how do i get a code to say 1 and higher

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