lua - 罗布洛克斯 || game.Players.LocalPlayer.Name 尝试调用字符串值?
问题描述
local Player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
if not Settings.CustomAppDesc then
AppDescLabel.Text("Welcome, "..Player.Name) -- Error: attempt to call a string value
end
不知道为什么会这样。
谢谢,尼克劳斯
解决方案
attempts to call a string value
不知道为什么会这样
好吧,为什么会发生这种情况实际上很明显。
AppDescLabel.Text("Welcome, "..Player.Name)
AppDescLabel.Text
就是,顾名思义,文本和文本存储在字符串值中。
将调用运算符放在()
字符串值之后是尝试调用对 Lua 没有任何意义的字符串值,因此不允许和拒绝并显示错误消息。
如果要设置 AppDescLable 的 Text 属性,则需要为其分配一个字符串值。
AppDescLabel.Text = "Welcome, " .. Player.Name
请参考https://developer.roblox.com/en-us/api-reference/property/TextLabel/Text
推荐阅读
- hybris - 更改 Hybris 中已经存在的列的长度?
- git - 将更改推送到源(上游)后如何将更改推送到另一个远程?
- python - Python:使用 pyinstaller 在可执行文件中包含 ui 文件
- python - np.array(filter(func,iter)) 不产生数组
- javascript - 如何通过 JavaScript 在 android webview 中监听页面 beforeunload 或 unload 事件
- node.js - 使用 npm-cli 时如何部署持续运行的应用程序
- javascript - AWS - 使用 API Gateway 使用 multipart/form-data 上传 CSV 文件
- nginx - Nginx 与 Cakephp 不一致的行为
- javascript - 是否可以通过 Javascript 捕获 Windows 系统音频
- postgresql - 如何在数据库中搜索近似词