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

How to make values change when its higher than a certain number?

Asked by 9 years ago

How do I make Y change its value when X's value is more than 10?

if x.Value == 10 then
    y.Value = 5
end

1 answer

Log in to vote
5
Answered by
duckwit 1404 Moderation Voter
9 years ago

Make sure that you are aware of the difference between a variable and a Value Instance. A Value Instance is an actual object that you can store in the ROBLOX game hierarchy, for example, in workspace or in a Player's Backpack, and they have a Value property that stores a value of a certain type. Examples are IntValue, StringValue, and CFrameValue - you can read about them on the Official ROBLOX Wiki.

Now, to answer your question, there are 6 relational operators in Lua:

== means "equal to"

~=means "not equal to"

< means "less than"

> means "greater than"

<= means "less than OR equal to"

>= means "greater than OR equal to"

In the excerpt that you posted, ChromeNine, you used the == 'relational operator', which means that you are checking if x is equal to 10. You want to be using > because you want to check if x is greater than 10.

if x > 10 then
    y = 5
end
Ad

Answer this question