【问题标题】:Removing a player's leaderstats if they click a gui on roblox如果玩家点击 roblox 上的 gui,则删除玩家的领导者统计信息
【发布时间】:2013-12-18 21:45:15
【问题描述】:

一些简单的代码

script.Parent.MouseButton1Up:connect(function()
    ????.leaderstats.lvl.Value = 0
    ????.leaderstats.xp.Value = 0
    ????.leaderstats.gold.Value = 0

它甚至不工作。所以玩家点击了gui,但是如何重置玩家的leaderstats,特别是lvl,xp和gold,我现在运行一个相当流行的roblox rpg游戏,大约有400人,这将是一个巨大的帮助。

【问题讨论】:

  • 尝试让你的回调接受一个参数。也许 mousebutton1up 事件将父级传递给它?
  • 播放器在哪里定义?全球的?在脚本中?
  • 它在脚本中。

标签: lua roblox


【解决方案1】:

您可以将以下代码放在按钮内的 LocalScript 中。

    Player = game.Players.LocalPlayer --Only works inside a localscript, replace with the line below it if you need it as a Script.
    -- Player=script.Parent while (not Player:IsA("Player")) do Player = Player.Parent end

    script.Parent.MouseButton1Up:connect(function()
        local index, stat
        for index, stat in pairs(Player.leaderstats:GetChildren()) do
            stat.Value = 0
        end
    end)

【讨论】:

    【解决方案2】:

    它应该在 LocalScript 中,因此您可以使用 LocalPlayer 变量来获取 leaderstats 并设置它们。

    【讨论】:

      猜你喜欢
      • 2019-11-10
      • 2018-10-26
      • 1970-01-01
      • 2021-12-28
      • 2021-10-17
      • 2022-10-05
      • 2019-06-26
      • 2022-11-28
      • 1970-01-01
      相关资源
      最近更新 更多