【问题标题】:This script is messing up这个脚本搞砸了
【发布时间】:2021-09-22 19:51:55
【问题描述】:

当我点击 5 次载入游戏时,它会消失,但不显示图像标签。 请帮忙!

local hits = 0
local model = script.Parent.Parent

game.StarterGui.Inventory.ImageLabel.Visible = false

script.Parent.ClickDetector.MouseClick:Connect(function()
    hits = hits + 1
    if hits > 4 then
        model.Union.Transparency = 1
        model.Union.CanCollide = false
        model.Part1.Transparency = 1
        model.Part1.CanCollide = false
        model.Part2.Transparency = 1
        model.Part2.CanCollide = false
        model.Part3.Transparency = 1
        model.Part3.CanCollide = false
        model.Part4.Transparency = 1
        model.Part4.CanCollide = false
        game.StarterGui.Inventory.ImageLabel.Visible = true
        wait(1)
        game.StarterGui.Inventory.ImageLabel.Visible = false
    end
end)

【问题讨论】:

  • 如果您从game.StarterGui.Inventory.ImageLabel.Visible 开始设置为true,在您点击5 次之前是否可见?
  • 不,因为我想做的是制作新版本的 booga booga。我试图让它在你开采它时显示,它会显示铁矿石的图像,然后在 1 秒后它会消失! @尼菲姆
  • 我明白,我的问题/建议是检查图像是否有效。通过最初将其设置为true,您应该会看到图像,如果您不这样做,您现在可以获得更多关于错误的信息,而不是继续点击5次并且它不会消失,再次详细了解具体没有的信息工作。
  • 我该如何解决? @尼菲姆
  • 使用 GetService。也可以尝试 waitforchild 而不是直接引用变量。

标签: lua roblox


【解决方案1】:

您需要在玩家的 PlayerGui 中设置 gui 的可见性。 StarterGui 是在玩家生成时为他们提供 gui 的服务。

local hits = 0
local model = script.Parent.Parent
local imageLabel = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Inventory"):WaitForChild("ImageLabel")

imageLabel.Visible = false

script.Parent.ClickDetector.MouseClick:Connect(function()
    hits = hits + 1
    if hits > 4 then
        model.Union.Transparency = 1
        model.Union.CanCollide = false
        model.Part1.Transparency = 1
        model.Part1.CanCollide = false
        model.Part2.Transparency = 1
        model.Part2.CanCollide = false
        model.Part3.Transparency = 1
        model.Part3.CanCollide = false
        model.Part4.Transparency = 1
        model.Part4.CanCollide = false
        imageLabel.Visible = true
        wait(1)
        imageLabel.Visible = false
    end
end)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多