这个脚本出现了问题

当我进入游戏并点击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)
点赞
用户16667848
用户16667848

你需要设置玩家的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)
2021-10-15 22:19:53