我需要两个变量用于lua中的for循环

我需要两个变量用于lua中的for循环,lua,Lua,我正在尝试用Lua代码在roblox中制作一个游戏,我希望圆柱体每0.0625秒变大一点,以制作一个类似冲击波的东西,脚本父对象是圆柱体部分 for i = 0,5,1 a = 1,0,-0.1 do script.Parent.Transparency = a script.Parent.Size = Vector3.new(script.Parent.Size.X, script.Parent.Size.Y = i, script.Parent.Size.Z = i) end

我正在尝试用Lua代码在roblox中制作一个游戏,我希望圆柱体每0.0625秒变大一点,以制作一个类似冲击波的东西,脚本父对象是圆柱体部分

for i = 0,5,1 a = 1,0,-0.1 do
    script.Parent.Transparency = a
    script.Parent.Size = Vector3.new(script.Parent.Size.X, script.Parent.Size.Y = i, script.Parent.Size.Z = i)
end

for循环中只能有一个控制变量。如果需要更多,则需要更多循环或管理循环体中的另一个变量

从你的帖子中不清楚需要什么样的解决方案

等同于代码:

 do
   local var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)
   if not (var and limit and step) then error() end
   var = var - step
   while true do
     var = var + step
     if (step >= 0 and var > limit) or (step < 0 and var < limit) then
       break
     end
     local v = var
     block
   end
 end
我跳过了大小为0的对象,因为我假设大小为0的对象不可见,那么为什么要更改它们的透明度呢

注意,我修复了代码中的语法错误

script.Parent.Size = Vector3.new(script.Parent.Size.X,
                       script.Parent.Size.Y = i, script.Parent.Size.Z = i)

将导致“=”附近出现
”)”错误,因为您可能无法在函数调用中赋值。

您需要两个循环,一个嵌套在另一个循环中。
for size = 1, 5 do
  script.Parent.Size = Vector3.new(script.Parent.Size.X, size, size)
  for transparency = 1, 0, -0.1 do
    script.Parent.Transparency = transparency
  end

end
script.Parent.Size = Vector3.new(script.Parent.Size.X,
                       script.Parent.Size.Y = i, script.Parent.Size.Z = i)