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

How do I make some of the decals at a different WatTime speed?

Asked by 9 years ago

I want like some of the decals to be like 5 seconds speed and the other ones to be like 2 to 4 seconds.

bin = script.Parent
decal = bin.Decal

WaitTime = 5.5 -- Wait 5.5 sec. to each decal

MainSlides = {"http://www.roblox.com/asset/?id=154539172", "http://www.roblox.com/asset/?id=177042272",
"http://www.roblox.com/asset/?id=157119414", "http://www.roblox.com/asset/?id=175271294",
"http://www.roblox.com/asset/?id=198632478"}

function runTable(table, delayTime)
    for i=1,#table do
        decal.Texture = table[i]
        wait(delayTime)
    end
end

while true do
    runTable(MainSlides, WaitTime)
end


I hope you understand what I am asking.

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

To do this you need to use a dictionary. Dictionaries are essentially tables with keys and values, and rather than indexing the table like table[2] you'd index it by the key, table['Key'].

So, lets make a dictionary with keys of the mainslide IDs, and values of the waitTime.

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=198632478"] = 5.5
["http://www.roblox.com/asset/?id=175271294"] = 5.5,
["http://www.roblox.com/asset/?id=157119414"] = 5.5, 
["http://www.roblox.com/asset/?id=177042272"] = 5.5,
["http://www.roblox.com/asset/?id=154539172"] = 5.5, 
}

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

while wait() do
    runTable(MainSlides)
end
0
So, dictionaries is a useful thing to do like this one. User#5689 -1 — 9y
0
Correct. Goulstem 8144 — 9y
1
It would probably be cleaner to just store the ID's in the table then concatenate them into the roblox.com/asset string in the loop. Either way works, however. Perci1 4988 — 9y
0
^I actually though about that but then decided against it because it's not completely necessary and I thought it might confuse OP Goulstem 8144 — 9y
View all comments (3 more)
0
Goulstem? When I tested this out, it went all backwards instead of starting from the first to last. User#5689 -1 — 9y
0
Oh that's weird lemme edit. Goulstem 8144 — 9y
0
Try det Goulstem 8144 — 9y
Ad

Answer this question