Ninjafox56
Ninjafox56

Reputation: 3

Code Is Saying "Attempt to compare number <= Instance"

It says

Players.ninjafox56.PlayerGui.Shop.ShopGui.LightSide.ChooseSideL:5: attempt to compare number <= Instance

Rank = game.Players.LocalPlayer.leaderstats.Rank
Power = game.Players.LocalPlayer.leaderstats.Power

if Power >= 10000 then
    Rank.Value = 'Light'
else
    script.Parent.Text = 'Not Enough Power'
    wait(3)
    script.Parent.Text = 'Light Side'
  end
end)

Upvotes: 0

Views: 2456

Answers (1)

Kylaaa
Kylaaa

Reputation: 7188

Since Power is an object inside leaderstats, I'm going to assume it's a NumberValue.

When you say

if Power >= 10000 then

You are comparing the NumberValue Instance against the number. You are not comparing the number stored inside Power to the number, that's where your error is coming from. To fix this, use the NumberValue's Value in the comparison:

if Power.Value >= 10000 then

Upvotes: 1

Related Questions