【发布时间】:2018-12-29 19:36:43
【问题描述】:
我正在尝试制作一个渐变到 1 透明度然后又回到 0 的球。 这是我的代码:
ball = script.Parent
trans = 0
while true do
if trans < 1 then
while trans < 1 do
ball.Transparency = trans
wait(0.1)
trans = trans + 0.1
end
end
if trans == 1 then
while trans <= 1 and trans >=0 do
ball.Transparency = trans
wait(0.1)
trans = trans -0.1
end
end
end
球确实消失了,但再也没有回来。此时游戏将冻结。有什么解决办法吗?谢谢!
更新:所以我今天尝试了以下代码,它工作正常,但是当我在 if 语句中将 if ball.Transparency == 1 替换为 trans == 1 时,会出现同样的问题。请解释一下谢谢!
while true do
ball = script.Parent
trans = 0
for i=0, 1, 0.1 do
trans = i
wait(0.1)
ball.Transparency = trans
end
if ball.Transparency == 1 then
for i = 1, 0, -0.1 do
trans = i
wait(0.1)
ball.Transparency = trans
end
end
end
【问题讨论】: