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

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

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

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.

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