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

Changing a Value in a script?

I'm trying to make a way that ends a script once it gets pass a curtain value. I tried using:

if a.value =>  3 then

end

but it completely stopped the script. http://developer.roblox.com/en-us/articles/Conditional-Statements-in-Lua I tried following this but it still stopped the script.

Here is the script, I didn't put the full script since the rest is irrelevant:

for i, badge in pairs(badges) do
            wait(1)
	
				a.Value += 1
				   
				player.PlayerGui.ScreenGui.Frame.TextLabel.Text = (a.Value).."/"..(numberofbadges)
				      
        end

It works fine if I leave it like that, but the text will sky rocket passed how I want it to be. For example it will go from how I want it 3/3 to 20/3.

If you know how to fix it, please let me know.

2 answers

✓ Accepted answer

Roblox Lua is case-sensitive. a.value returns nil while a.Value returns the actual value. The script is breaking because you tried to compare nil to a number value. Try replacing a.value with a.Value in the first line.

It has to be >=, not =>. Also, just use +, += doesn’t do anything. Heres is a script example:

local Val = game.ReplicatedStorage.IntValue.Value
 if Val >= 3 then
    print(Val)
end

Also, here is some info on this:

== [Equal to]
~= [Not equal to]
> [Greater than]
< [Less than]
>= [Equal to or greater than]
<= [Equal to or less than]

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