滚动效果无法正常工作

我一直在 ROBLOX 中制作一个小游戏,其中一个问题是当它正在选择游戏时需要一个滚动效果。您可以在这里看到我在说什么。此外,在这个 gif 中,您可以看到我的问题。效果从下到上滚动。它应该从上到下。

我不知道为什么会这样,所以我也不知道该怎么做。

这是负责效果的代码:

for i,v in pairs(P:GetChildren()) do
    local ll
    local lastpicked
    local t = P:GetChildren()
    local menuItems =#t -- 菜单项数量
    local repeats = 1 -- 重复
    for R = math.random(65,95) + math.random(menuItems),1-1 do
        ll = t[repeats].SurfaceGui.TextLabel
        local lastbcolor = ll.BackgroundColor3
        ll.BackgroundColor3 = BrickColor.Yellow ().Color
        wait( R^-.7*.7 ) --
        ll.BackgroundColor3 = lastbcolor
        repeats = repeats % menuItems + 1
    end
    ll = t[repeats].SurfaceGui.TextLabel
    for R = 15 do
        local lastbcolor = ll.BackgroundColor3
        ll.BackgroundColor3 = BrickColor.new("Bright green").Color
        wait ( 0.3 )
        ll.BackgroundColor3 = lastbcolor
        lastpicked = ll
        map = maps:FindFirstChild(ll.Text):克隆()
        wait ( 0.3 )
    end
    破坏
end
点赞
用户8076767
用户8076767

这一行代码

for R = math.random(65,95) + math.random(menuItems), 1, -1 do

让你以相反的方向进行遍历。 给定代码

for R = a, b, c do

aR 的起始值,bR 的结束值,c 是增量。 现在的方式是从最后一个值往第一个值进行。试着将其改为

for 1, R = math.random(65,95) + math.random(menuItems), 1 do

这样行吗?

注意:你可以简化那段代码,省略结尾的 ,1

for 1, R = math.random(65,95) + math.random(menuItems) do

你可以这样做,因为如果省略 c,它会有一个隐含的值为 1。

2018-03-21 09:43:11