簡體   English   中英

無法分配屬性文本。 預期字符串,得到實例

[英]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

Text應該是一個字符串。 RandomText是一個實例。 就像錯誤告訴你的那樣。 Choices是什么類型,例如CallTexts的子項? 他們有 getter/toString 嗎?

如果它們是StringValue ,您將需要RandomText.Value

如果它們是TextLabel s (你的情況),你將需要RandomText.ContentText

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM