循环并将字符添加到 LUA 中的字符串



这是关于Lua/Roblox的。(免责声明:必须与 roblox 兼容。我有一个名为"array1"的数组,以及一个数字值"num",它是 0。

local array1 = {"1","2","3","etc."}
local num = 0

我愿意:

while 1 do
wait(1) -- just a little delay between loops
num = num + 1 -- every loop I'm increasing that "num" value with 1.
script.Parent.TextLabel.Text = array1[num] -- I'm setting Text to [num]th (in this case 1) of array1. (I get 1st, 2nd, 3rd, 4th etc. word every second)
end

它有效。有点。我的问题是,它将其设置为: "1"然后只有"2",而不是"1",然后是"12"。

以下是该问题的一些视频:https://i.stack.imgur.com/gAsig.jpg

我不希望那样。我希望它是:

1, 12, 123.

试试这个:

script.Parent.TextLabel.Text = script.Parent.TextLabel.Text .. array1[num]

这会将上一个Text值与下一个数字连接起来。

最新更新