I want my gui to repeatedly change imageID after a second, in which I tried to make it simply easier to script by making a table. I have no absolute idea on why this won’t work, this is a localscript inside of an imagelabel, in which the imagelabel is inside of a frame and screengui.
THE SCRIPTING:
local image = script.Parent
local images = {
['Image1'] = 9908022439;
['Image2'] = 7159053777; --These are random images I found on the marketplace.
['Image3'] = 14895788903;
}
while true do
task.wait(1)
image = image[math.random(1, #image)]
end
Not just that but the for 1,10 do highlights the 1 in red, and as I suspect I check the console and it displays:
Expected Identifier when parsing variable name, got '1'
I have done so, but unfortunately this has not fixed the issue. I have checked the console, as it does say the following error:
attempt to get length of a instance value
This is the changes I made:
local image = script.Parent
local images = {
9908022439;
7159053777;
14895788903;
}
while true do
task.wait(1)
image = image[math.random(1, #image)]
end
local image = script.Parent
local images = {
['Image1'] = 9908022439;
['Image2'] = 7159053777; --These are random images I found on the marketplace.
['Image3'] = 14895788903;
}
while true do
task.wait(1)
image = images["Image" ..math.random(1, #image)]
end
Firstly, you’re trying to get the length of “image” instead of “images”. Secondly, I don’t think using the length operator works for dictionaries - so if you don’t need the keys, I recommend just making it a plain table like images = { 1234, ... }.