尝试比较 lua 的字符串和数字类型

script.Parent.Yes.MouseButton1Click:connect(function()
    if game.Players.LocalPlayer.leaderstats.Stage.Value < 20 and db then
        db = false
        script.Parent.Question.Text = "你需要至少完成20个阶段才能重生!"
        wait(3)
        script.Parent.Visible = false
        open = false
        db = true
    elseif db then
        game.ReplicatedStorage.Rebirth:FireServer()
        script.Parent.Visible = false
        open = false
    end
end)

为什么第2行会报错,提示尝试比较字符串和数字类型?

点赞
用户88888888
用户88888888

这意味着 game.Players.LocalPlayer.leaderstats.Stage.Value 是一个字符串。我不知道 leaderstats 如何工作,但我认为你无意中将它变成了一个字符串,而不是一个数字。

2020-07-05 20:01:43