player.endersam777.playergui.currency.money.localscript:5:尝试调用一个数字值

发布于 2025-01-28 13:54:48 字数 266 浏览 1 评论 0原文

因此,我正在制作类似排行榜上的货币之类的东西,将在文本标签上。我该如何制作类似的东西不会显示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 技术交流群。

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

发布评论

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

评论(2

长亭外,古道边 2025-02-04 13:54:49

您可以使用串联字符串..
示例:

local player = game:GetService("Players").LocalPlayer

script.Parent.Text = tostring(player.leaderstats.Coins.Value).."$"

结帐 pil 3.4 以获取更多示例。

You can concatenate strings using ..
Example:

local player = game:GetService("Players").LocalPlayer

script.Parent.Text = tostring(player.leaderstats.Coins.Value).."
quot;

Checkout the PIL 3.4 for more examples.

屌丝范 2025-02-04 13:54:49

另一个答案告诉您如何解决问题,因此我将添加一些其他信息。

您遇到错误的原因是因为LUA调用如何函数。通常,您会调用这样的函数:

print("hello world")

...在参数周围使用括号的位置。但是,当您仅向功能提供一个参数时,您可以省略括号,它仍然可以使用:

print "hello world"

因此,在您的代码中,因为您彼此相邻两个值:

                     ↓ value 1                      ↓ value 2
script.Parent.Text = player.leaderstats.Coins.Value"$"

...解释器看到了这一点,并认为该值该值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 :

print("hello world")

... 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 :

print "hello world"

So in your code, because you have two values right next to each other :

                     ↓ value 1                      ↓ value 2
script.Parent.Text = player.leaderstats.Coins.Value"
quot;

... 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 error Attempt 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

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