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

What is wrong with this script?

Asked by 9 years ago

I asked this question before, and it worked :D. But when I tried it out, it went like out of order. Instead of starting from the first to the last, it did it backward. What is wrong with it?

local bin = script.Parent
local decal = bin.Decal
--The numbers(5.5) are how long to wait for each slide.
local MainSlides = {
["http://www.roblox.com/asset/?id=213163470"] = 15, 
["http://www.roblox.com/asset/?id=213486920"] = 3,
["http://www.roblox.com/asset/?id=157656296"] = 3,
["http://www.roblox.com/asset/?id=213486967"] = 3, 
["http://www.roblox.com/asset/?id=151111211"] = 3,
["http://www.roblox.com/asset/?id=213487020"] = 3
}

function runTable(tab)
    for i,v in pairs(tab) do
        decal.Texture = i
        wait(v)
    end
end

while wait() do
    runTable(MainSlides)
end

1 answer

Log in to vote
0
Answered by
bobder2 135
9 years ago

Line 14 says for i,v in pairs(tab) do This will iterate through the table in some weird order. Instead use ipairs which means iterated pairs. This will go through the table in order.

for i,v in ipairs(tab) do

0
Thanks bro. :D User#5689 -1 — 9y
0
Okay, I tested it out, but it is like froze. It only shows the decal of it. User#5689 -1 — 9y
Ad

Answer this question