无法分配属性文本。琴弦预期,有实例

发布于 2025-01-27 08:13:49 字数 594 浏览 1 评论 0原文

我正在制作随机的文本脚本(不要介意声音),并且得到了此错误:无法分配属性文本。弦乐预期,有实例。

while thing == true do
    wait(math.random(3, 12))
    local txts = game.ServerStorage.CallTexts:GetChildren()
    local Choices = script:GetChildren()
    local RandomIndex = math.random(1, #Choices)
    local RandomSound = Choices[RandomIndex]
    local RandomTextIndex = math.random(1, #txts)
    local RandomText = Choices[RandomTextIndex]
    RandomSound:Play()
    game.Workspace["Talking Ben's Room"].furniture.desk.phone["De Text"].BilBord.toxt.Text = RandomText
    wait(RandomSound.TimeLength) 
    end

I was making random text script (dont mind the sounds thing) and I got this error: Unable to assign property Text. string expected, got Instance.

while thing == true do
    wait(math.random(3, 12))
    local txts = game.ServerStorage.CallTexts:GetChildren()
    local Choices = script:GetChildren()
    local RandomIndex = math.random(1, #Choices)
    local RandomSound = Choices[RandomIndex]
    local RandomTextIndex = math.random(1, #txts)
    local RandomText = Choices[RandomTextIndex]
    RandomSound:Play()
    game.Workspace["Talking Ben's Room"].furniture.desk.phone["De Text"].BilBord.toxt.Text = RandomText
    wait(RandomSound.TimeLength) 
    end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守望孤独 2025-02-03 08:13:49

文本应该是字符串。 RandomText是一个实例。就像错误告诉你的一样。哪种类型选择,例如CallTexts的孩子?他们有一个get/to刺吗?

如果它们是String Value s,则需要RandomText.Value

如果是 textlabel s (您的情况),您将需要andarte> rancomtext.contenttext.contenttext

Text should be a string. RandomText is an Instance. Like the error told you. What type are the Choices, e.g. the children of CallTexts? Do they have a getter/toString?

If they are StringValues you will need RandomText.Value

If they are TextLabels (your case), you will need RandomText.ContentText

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文