滚动效果无法正常工作

Scroll effect isn't working correctly

我在 ROBLOX 中制作小游戏已经有一段时间了,我的游戏中有一个东西是选择游戏时的滚动效果。你可以看到我在说什么here。同样在此 gif 中,您可以看到我的问题。效果从下往上滚动。它应该从上到下。

我真的不明白为什么要这样做,所以我不确定该怎么做。

下面是负责效果的代码:

for i, v in pairs(P:GetChildren()) do
    local ll
    local lastpicked        
    local t = P:GetChildren()
    local menuItems = #t -- number of menu items
    local repeats = 1 -- Repeated
    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 = 1, 5 do
        local lastbcolor = ll.BackgroundColor3
        ll.BackgroundColor3 = BrickColor.new("Bright green").Color
        wait( .3 )
        ll.BackgroundColor3 = lastbcolor
        lastpicked = ll
        map = maps:FindFirstChild(ll.Text):Clone()
        wait( .3 )
    end
    break
end

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。