You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OreString值输出正常但界面显示未更新的问题求助

问题解决:OreString界面显示不更新

你的问题核心是界面控件的属性赋值错误:

  • 你代码里的OreString指向的是界面元素(比如TextLabel),但你一直在给它的Value属性赋值,而这类控件的显示文本是由Text属性控制的。
  • print(OreString.Value)能输出是因为Lua允许动态给对象加属性,但这个自定义的Value和界面显示完全无关,所以界面不会变化。

修复方案

把按钮点击事件里的赋值语句改成修改Text属性:

local proximityprompt = game.Workspace.Tycoons.Tycoon.MainItems.Cardboard_Box.Box.ProximityPrompt
local StorageGui = script.Parent
local x = script.Parent.Storage.Frame.X

local Orebuttons = script.Parent.Storage.Frame.Ores:GetChildren()
local OreString = script.Parent.Parent.Sell.Frame.Ore

proximityprompt.Triggered:Connect(function()
    StorageGui.Visible = true
end)
x.MouseButton1Click:Connect(function()
    StorageGui.Visible = false
end)
for _, button: GuiButton in pairs(Orebuttons) do
    if button:IsA("GuiButton") then
        button.MouseButton1Click:Connect(function()
            -- 把Value改成Text
            OreString.Text = button.Name
        end)
    end
end

额外检查点

  • 确认Sell.Frame.Ore确实是TextLabel/TextButton这类支持Text属性的控件,不是Frame或其他非文本控件。
  • 如果你的设计是用StringValue这类数据对象来中转数据,那需要给StringValue绑定Changed事件,自动同步到界面:
    -- 假设OreString是StringValue对象
    OreString.Changed:Connect(function(newValue)
        script.Parent.Parent.Sell.Frame.Ore.Text = newValue
    end)
    

内容的提问来源于stack exchange,提问作者Sodz1aX

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 05:05:05