Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to add ... in this script? :D

I made this script, but what I can't figure out is adding sounds to some of the decals for when it shows them, but I also want some pictures to go either fast or slow. So like 10 of them goes like 2.5 sec and the other one is like 5 sec. This is the script what I put so far:

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 am sorry if I am not smart to do it. Thank you!

1 answer

✓ Accepted answer

Use math.random() to achieve this:

local bin = script.Parent
local decal = bin.Decal

local 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"}

local SoundsForSlides = {12222030} -- Add more if you wish, will play with the slide

local function runTable(table, delayTime)
    for i=1,#table do
        decal.Texture = table[i]
        wait(math.random(2, 5)) --The time can vary from 2 to 5 seconds.
		if SoundsForSlides[i] then
			SoundsForSlides[i]:Play() --If this doesn't work tell me
		end
    end
end

while wait() do
    runTable(MainSlides, WaitTime)
end

1 comment

0

They said there is an error: 13:33:57.047 - Workspace.Part.SlideScript:15: attempt to index field '?' (a number value)

This discussion is preserved as it was. New answers, comments, and votes are closed.