Ad
Log in to vote
0

Why is the function only working on one of the advertisements?

Asked by 12 days ago

I made a script that perfectly works for only one of the ad boards, the rest wont tween

local Module = {}

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

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


local function SetupScreenMovement(Part)
    warn(Part)

    --< variables
    local Display1 = Part.SurfaceGui.Frame.Display1
    local Display2 = Part.SurfaceGui.Frame.Display2

    local using = Display1

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

            --< 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)
        end
    end
end


function Module:SetupAds()
    for P,Model in pairs(game.workspace.Game.AdvertBoards:GetChildren()) do
        if Model:IsA('Model')and Model.Name == "BigBannerAd" or Model.Name == "SmallBannerAd" then do

                for Model,Part in pairs(Model:GetChildren()) do
                    if Part:IsA('Part')and Part.Name == "Screen" then

                        SetupScreenMovement(Part)
                    end
                end
            end
        end
    end
end     

return Module

0
Once you have "while" running, it runs until it's stopped so it never reached the one below it. Try "spawn(function() SetupScreenMovement(Part) end)" on line 59. 9mze 178 — 9d

Answer this question