Ad
Log in to vote
0

How do i make a code saying 1 or higher because im trying to make an attributes thing?

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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
thx xxbrobroxx02 11 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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.

0
do u know how to make the camera follow an animation xxbrobroxx02 11 — 2y
0
Checkout the Cutsecen Editor by CloneTrooper1019. Also, accept the answer if it helped! Michael_TheCreator 166 — 2y
0
make the HumanoidRootPart the CameraSubject and vice versa DeceptiveCaster 3687 — 2y
0
^^ Michael_TheCreator 166 — 2y
0
how do i get a code to say 1 and higher xxbrobroxx02 11 — 2y

Answer this question