2017-05-30 1 views
0

Je fais un effet dans mon jeu où il fait défiler certains choix et ralentit jusqu'à un arrêt sur un choix.Effet n'apparaissant pas sur guis

Il y a 4 écrans et je veux que chacun joue l'effet simultanément, tous les guis apparaissent en même temps mais l'effet ne joue jamais. J'ai marqué la partie du code qui fait l'effet dans le bloc de code ci-dessous:

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 

Répondre

1

Hope this helps:

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 

Je ne suis pas sûr que je reçois tout à fait ce que vous faites ici ou comment vous avez des choses mises en place, mais en général, vous devriez essayer de déplacer coroutines/fonctions engendrées à l'extérieur des boucles.