首页 > 解决方案 > Roblox Lua 错误值不是 Player 的有效成员,但我不尝试访问它

问题描述

我正在尝试在 Roblox 上制作游戏,不久前我遇到了一个错误,我找不到修复并放弃了,我刚刚开始尝试再次修复它。当我尝试检查玩家是否有能力购买该物品时,我收到错误 Value is not a valid member of Player,这是我的代码来自错误的来源

game:GetService("ReplicatedStorage"):WaitForChild("Shop"):WaitForChild("UpgradeClicks").OnServerEvent:Connect(function(player, price)
    if player.leaderstats.Views.Value <= price.Value then
        print("test")
    end
end)

这是按下按钮时发生的代码

local RE = game:GetService("ReplicatedStorage").Shop.UpgradeClicks
local button = script.Parent
local price = script.Parent.Price
local player = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
    RE:FireServer(player, price)
end)

标签: luaroblox

解决方案


尝试在不输入播放器变量的情况下调用 fireserver。


推荐阅读