player.endersam777.playergui.currency.money.localscript:5:尝试调用一个数字值
因此,我正在制作类似排行榜上的货币之类的东西,将在文本标签上。我该如何制作类似的东西不会显示0 $?因为如果我要添加script.parent.text = player.leaderstats.coins.value“ $”,它将无法使用。脚本:
local player = game:GetService("Players").LocalPlayer
script.Parent.Text = player.leaderstats.Coins.Value
So, I was making something like the currency on leaderboard will be on a TextLabel. How can I make something like it will not be showing 0 but 0$? Because if I will put script.Parent.Text = player.leaderstats.Coins.Value"$" it will not work. Script:
local player = game:GetService("Players").LocalPlayer
script.Parent.Text = player.leaderstats.Coins.Value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
串联字符串..
示例:
结帐 pil 3.4 以获取更多示例。
You can concatenate strings using
..
Example:
Checkout the PIL 3.4 for more examples.
另一个答案告诉您如何解决问题,因此我将添加一些其他信息。
您遇到错误的原因是因为LUA调用如何函数。通常,您会调用这样的函数:
...在参数周围使用括号的位置。但是,当您仅向功能提供一个参数时,您可以省略括号,它仍然可以使用:
因此,在您的代码中,因为您彼此相邻两个值:
...解释器看到了这一点,并认为该值该值1是一个函数,值2是您传递给它的参数,并且它正在抛出错误,因为
player.leaderstats.coins.coins.value
不是一个函数,它是一个数字。这就是为什么您要获得错误尝试调用号码值
(例如函数)的原因。在此答案中可以找到其他一些用于连接字符串的替代方法: >
The other answer tells you how to fix your problem, so I'll just add some additional information.
The reason you are getting an error is because of how lua calls functions. Usually you would call a function like this :
... where you use parentheses around the arguments. However, when you only provide one argument to the function, you can omit the parentheses and it will still work :
So in your code, because you have two values right next to each other :
... the interpreter sees this and thinks that value 1 is a function, and value 2 is the argument you are passing to it, and it is throwing an error because
player.leaderstats.Coins.Value
is not a function, it's a number. That's why you are getting the errorAttempt to call a number value
(like a function).And some other alternatives for concatenating strings can be found in this answer : https://stackoverflow.com/a/21792185/2860267