Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this only happening to only one banner? i want it to work with all of them

Asked by 5 years ago
Edited 5 years ago
function Module:Ads()
    print("ADVERTISMENT")

    --< Getting the Advert boards
    local AdvertBoardLocations  = workspace.Game.AdvertBoards
    local Children              = AdvertBoardLocations:GetChildren()

    for i = 1, #Children do
        if Children[i]:IsA('Model') and Children[i].name == "SmallBannerAd" then

            --< variables
            local Display1 = Children[i].Screen.SurfaceGui.Frame.Display1
            local Display2 = Children[i].Screen.SurfaceGui.Frame.Display2   

            local using = Display1

            --< dialogue
            local Display = 
            {
                "rbxassetid://1577225448", 
                "rbxassetid://1577224943", 
                "rbxassetid://1577225448", 
                "rbxassetid://1577224943"
            }

            warn("GOT IDS")

            --< move function (tween)
            local function move(obj, pos)
                obj:TweenPosition(pos, "Out", "Quad", 1)
            end


            while true do
                --< dialogue runner (for loop)
                for s = 1, #Display do

                    warn("TWEENED")

                    --< reposition, change text, and move current label onto screen
                    using.Position = UDim2.new(-1, 0, 0, 0)
                    using.Image = Display[s]
                    move(using, UDim2.new(0, 0, 0, 0))

                    --< prepare next label
                    if using == Display1 then
                        using = Display2
                    else
                        using = Display1
                    end

                    --< move old/next label off the screen
                    move(using, UDim2.new(1, 0, 0, 0))

                    wait(2)
                    warn("WAITED")
                end
            end
        end
    end
end 

Answer this question