无法分配属性文本。琴弦预期,有实例
我正在制作随机的文本脚本(不要介意声音),并且得到了此错误:无法分配属性文本。弦乐预期,有实例。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文本
应该是字符串。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 theChoices
, e.g. the children ofCallTexts
? Do they have a getter/toString?If they are
StringValue
s you will needRandomText.Value
If they are
TextLabel
s (your case), you will needRandomText.ContentText