代码说“尝试比较数字 <= 实例" [英] Code Is Saying &quot;Attempt to compare number &lt;= Instance&quot;

查看:17
本文介绍了代码说“尝试比较数字 <= 实例"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它说

Players.ninjafox56.PlayerGui.Shop.ShopGui.LightSide.ChooseSideL:5:尝试比较数字 <= Instance

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)

推荐答案

由于 Powerleaderstats 中的一个对象,我将假设它是一个 NumberValue.

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

当你说

if Power >= 10000 then

您正在将 NumberValue Instance 与数字进行比较.您没有将 Power 中存储的数字与数字进行比较,这就是您的错误的来源.要解决此问题,请在对比:

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

这篇关于代码说“尝试比较数字 <= 实例"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆