What is wrong with this code?

while true do
	repeat
		wait()
	until exp.Value => maxexp.Value
	exp.Value = 0
	level.Value = level.Value + 1
	maxexp.Value = maxexp.Value * 1.1
end

The “=” is getting underlined in red

And the error that appears is:
Players.taimojai.PlayerScripts.Leveling System:10: Expected identifier when parsing expression, got ‘=’

1 Like

If you’re using the repeat-until statement to wait until the exp.Value is greater than the maxexp.Value, it’s possible you may have made a typo where you meant to type >= operator.

Also, if the exp.Value is a ValueBase (IntValue, StringValue, etc) then why not connect the Changed event of the IntValue to a function? This would have an argument passed to it, representing the new value it was changed to.
Then, you could check if the parameter greater than the maxep.Value?

4 Likes

I can’t test it right now but I guess it’s >= instead of =>.

Also, you should use signals for that:

exp:GetPropertyChangedSignal('Value'):Connect(function()
   if exp.Value >= maxexp.Value then
      exp.Value = 0
      level.Value += 1
      maxexp.Value *= 1.1
   end
end)
2 Likes

You dont need a getpropertysignal event so just do

exp.Changed:Connect(function(value) -- current value what has been changed
end)

1 Like

But doesn’t it fire when some other property changes?

1 Like

The problem was the >= typo, everything else works fine now

1 Like

Values like Boolvalues,intvalues,stringvalues,colorvalues,any value Instance has their own special .Changed event so it includes an argument which is the Current changed state

etc etc

I just learnt this just now and i hope im not getting it wrong

1 Like

Oh, I see it now. I’ll start using it instead of GetPropertyChangedSignal, it’s pretty simpler. Thank you a lot :+1:

1 Like

But with other instances that are not Values and has other properties you would use GetpropertyChangedSignal

1 Like