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

Error saying: attempt to compare userdata with number. Help me understand?

Asked by 5 years ago

if Player.PlayerStats.CurrentValue < Player.PlayerStats.Storage.Value then

if Debounce == false then

Debounce = true

CoinClicked:FireServer(Strength.Value)

wait (0.25)

Debounce = false

end

-tell me what I have done wrong?

1 answer

Log in to vote
0
Answered by 5 years ago

The error is right here:

if Player.PlayerStats.CurrentValue < Player.PlayerStats.Strength.Value then

Odds are that CurrentValue is either an IntValue or a NumberValue. If so, use its Value property to compare it with another value's Value property:

if Player.PlayerStats.CurrentValue.Value < Player.PlayerStats.CurrentValue.Value then

The error itself is self-explanatory: attempt to compare userdata with number. CurrentValue is an Instance, and because all Instances are userdata values, you are comparing two things with different data types. CurrentValue.Value is a number value, and should fix your problem.

Ad

Answer this question