【问题标题】:Cloned Gui Frame from ReplicatedStorage is parented in StarterGui, but still not visible来自 ReplicatedStorage 的克隆 Gui 框架在 StarterGui 中是父级,但仍然不可见
【发布时间】:2021-08-02 11:16:19
【问题描述】:

我正在尝试从 ReplicatedStorage 克隆一个框架并将其作为 StarterGui 中另一个框架的父级。我希望看到框架中的文本,但不能。当我在编辑器中手动复制 ReplicatedStorage 中的框架并将其拖动到 StarterGui 中的框架时,它工作正常,并且我看到可以看到文本。没有错误或警告。当我运行脚本并调用 updateDisplay 函数时,我可以从 ReplicatedStorage 中看到并移动框架的边缘,但看不到文本。

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")

local updateResourceDisplay = ReplicatedStorage:WaitForChild("UpdateResourceDisplay")

local function updateDisplay(resources)
    for key, value in pairs(resources) do
        local newResource = ReplicatedStorage.ResourceTemplate:Clone()
        newResource.Parent = StarterGui.ScreenGui.LeftFrame.Frame
    end
end

updateResourceDisplay.OnClientEvent:Connect(updateDisplay)

【问题讨论】:

    标签: roblox


    【解决方案1】:

    原来 StarterGui 仅用于...开始。如果您想在运行时更改播放器的 gui,则使用 PlayerGui 而不是 StarterGui。将第二行更改为以下代码并将 StarterGui 的引用替换为 PlayerGui 有效:

    local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
    

    【讨论】:

      猜你喜欢
      • 2021-08-17
      • 1970-01-01
      • 1970-01-01
      • 2017-02-09
      • 2011-07-08
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多