【问题标题】:Lua Refreshing Script (ROBLOX)Lua 刷新脚本 (ROBLOX)
【发布时间】:2020-07-02 02:38:34
【问题描述】:

我正在努力在 ROBLOX 中创建一个播放器 GUI。 GUI 应该显示玩家的钱,可悲的是,当我测试它并尝试更新玩家的硬币时,GUI 不会随之更新。我添加了一个旧代码,因为它适用于我正在使用不同语言处理的旧项目。当我添加它时,我真的不知道我在想什么。

代码如下:

local player = game.Players.LocalPlayer
coinAmount = player:WaitForChild("leaderstats"):WaitForChild("Coins")
oldCoinAmount = player:WaitForChild("leaderstats"):WaitForChild("Coins")
text = script.Parent

if coinAmount ~= oldCoinAmount then
    text = oldCoinAmount
end

我在想也许有办法不断刷新脚本,但我不知道如何。

此外,此 LocalScript 是实际 GUI 的子代 它也不会抛出任何错误。

【问题讨论】:

    标签: user-interface text lua roblox


    【解决方案1】:

    我想通了,如果你想这样做,你可以使用这个脚本:

    local player = game.Players.LocalPlayer
    coinAmount = player:WaitForChild("leaderstats"):WaitForChild("Coins")
    text = script.Parent
    
    coinAmount.Changed:connect(function()
        text.Text = coinAmount.Value .. " Coins"
    end)
    

    【讨论】:

      猜你喜欢
      • 2023-01-26
      • 2016-03-31
      • 1970-01-01
      • 2022-10-20
      • 2022-07-12
      • 2020-06-23
      • 2011-05-24
      • 2019-10-15
      • 2018-11-26
      相关资源
      最近更新 更多