【问题标题】:Trying to Make a Sell Area for a ROBLOX Game尝试为 ROBLOX 游戏开辟销售区域
【发布时间】:2020-12-12 04:04:46
【问题描述】:

我正在尝试为我的大厅打造一个 ROBLOX 游戏的销售区域。

然而,每当我踏上销售区域(有积分)时,我似乎没有得到任何现金,我的积分也没有改变。

请帮忙?

这是我的代码:

local sellPart = script.Parent

game.Players.PlayerAdded:Connect(function(plr)
    sellPart.Touched:Connect(function(hit)
        local hrp = hit.Parent:FindFirstChild("HumanoidRootPart")
        if hrp then
            local player = game.Players:GetPlayerFromCharacter(hrp.Parent)
        
            local zombpoints = player.leaderstats.Zombpoints
            local zombcash = player.leaderstats.Zombcash
        
            zombcash = zombpoints
            zombpoints = 0
        end
    end)
end)

希望这会有所帮助。

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    在您的代码中,您将 NumberValue 对象存储到变量中,然后覆盖这些变量。您没有修改存储在变量中的数据。

    所以当你使用NumberValues时,你需要显式设置它们的Value属性。

    -- get the point values out of the leaderstats
    local zombpoints = player.leaderstats.Zombpoints
    local zombcash = player.leaderstats.Zombcash
    
    -- convert the points to cash and add it to cash pile
    zombcash.Value = zomcash.Value + zombpoints.Value
    
    -- reset the point counter
    zombpoints.Value = 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-07
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      • 2020-12-17
      • 2021-12-20
      • 2020-09-05
      相关资源
      最近更新 更多