Roblox 商店无法显示

这是为我的游戏。我所有代码都是正确的,没有错误。

script.Parent.MouseButton1Click:Connect(function()
    game.StarterGui.ScreenGui.Enabled = true
    script.Parent.Visible = false
end)

但是当我开始游戏时,代码无法正常工作,只有商店按钮消失了,即:"script.Parent.Visible = false",并且显示商店的"game.StarterGui.ScreenGui.Enabled = true"无法工作,不会显示商店,是的我已经禁用了 ScreenGui,也没有输出错误。

点赞
用户10833908
用户10833908

你需要确保使用本地的 StarterGui

当你执行 game.StarterGui.ScreenGui.Enabled = true 时,你改变的是全局实例而不是本地实例。要修复这个问题,你需要使用 script.Parent 而不是 game.StarterGui。 以下是一些示例代码:

script.Parent.MouseButton1Click:Connect(function()
script.Parent.%需要多少个父级才能回到StarterGui%.ScreenGui.Enabled = true
script.Parent.Visible = false
end)
2019-12-05 19:14:21
用户10823924
用户10823924

在第二行,您正在启用位于 StarterGui 而不是 PlayerGui 中的 GUI。要解决这个问题,请将代码更改为:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
    script.Parent.Visible = false
end)

此外,下次发帖时,请使用 {} 按钮来包含代码。

2019-12-08 00:39:28