效果未显示在 guis 上

Effect not showing up on guis

我正在我的游戏中制作一种效果,它会滚动浏览一些选项并在选择一个选项时减速到停止。

有4个画面,我想让每个画面同时播放效果,所有的guis同时出现,但效果不播放。我在下面的代码块中标记了执行效果的代码部分:

message.chooseduel = function(spins)
    local lobby=workspace.Lobby
    local screens=lobby.Screens
    local n1,n2
    for _, screen in pairs(screens:GetChildren()) do
        local gui=screen.SurfaceGui
        local ds=gui.DuelScreen
        gui.Enabled=true
        for i, v in pairs(ds.Container:GetChildren()) do
            local ll
            local lastpicked       
            local t = ds.Container:GetChildren()
            local menuItems = #t -- number of menu items
            local repeats = 1 -- Repeated
            for R = 65 + spins, 1, -1 do
                ll = t[repeats]
                if ll:IsA("GuiObject") then
                    --**effect**--
                    local newgui = coroutine.wrap(function()
                    print("HI!")
                    ll.BackgroundColor3=Color3.fromRGB(130, 125, 56)
                    wait( R^-.7*.7 ) --
                    ll.BackgroundColor3=ll.BorderColor3
                    repeats = repeats % menuItems + 1
                    end)
                    newgui()
                    --**effect**--
                end
            end
            ll = t[repeats]
            ll.BackgroundColor3=Color3.fromRGB(230, 225, 156)
            n1=string.sub(ll.n1.Image,64)
            n2=string.sub(ll.n2.Image,64)
            print("Returning:",n1,n2)
        end
    end
    wait(2)
    return {n1,n2}
end

希望这对您有所帮助:

message.chooseduel = function(spins)
    spins = math.ceil(spins)  -- just making sure.
    local lobby=workspace.Lobby
    local screens=lobby.Screens
    local n1,n2
    for _, screen in pairs(screens:GetChildren()) do
        local gui=screen.SurfaceGui
        local ds=gui.DuelScreen
        gui.Enabled=true
        spawn(function() -- I think this is where the coroutine / async function should start
            local ll
            local lastpicked -- Variable not used
            local t = ds.Container:GetChildren()
            local numMenuItems = #t -- number of menu items
            local current = 1 -- Repeated
            print("HI!")
            for R = 65 + spins, 1, -1 do
                ll = t[current]
                if ll:IsA("GuiObject") then
                    ll.BackgroundColor3=Color3.fromRGB(130, 125, 56)
                    wait( R^-.7*.7 ) --
                    ll.BackgroundColor3=ll.BorderColor3
                    current = current % numMenuItems + 1
                end
            end
            print("BYE!")
            ll = t[current]
            ll.BackgroundColor3=Color3.fromRGB(230, 225, 156)
            n1=string.sub(ll.n1.Image,64) -- um... Interesting. wait what?
            n2=string.sub(ll.n2.Image,64)
            print("Returning:",n1,n2)
        end)
    end
    wait(2)
    return {n1,n2}
end

我不确定我是否完全理解您在这里所做的事情或您是如何设置的,但通常您应该尝试将协程/派生函数移动到循环外部。