Hello,
Recently, I have been working on a system which displays background images on my game: https://www.roblox.com/games/225780602/The-Arc
I wanted to create a system that changed between multiple pictures in a loop.
With this in mind, I created a gui: https://cdn.discordapp.com/attachments/356675974928007168/531941278330650634/unknown.png
I then added the script, with a few trial images:
local back1 = script.Parent
local back2 = script.Parent.Parent:FindFirstChild("Background2")
images = {2721116470, 2673015024, 1417408619, 1417402706}
local one = 1
local two = 2
back1.Image = (images[one])
back2.Image = (images[two])
local function change1()
local succ,err = pcall(function()
if one > #images then
one = 1
else
back1.Image = "http://www.roblox.com/asset/?id=" .. (images[one])
end
end)
if err then
change1()
end
end
local function change2()
local succ2,err2 = pcall(function()
if two > #images then
two = 2
else
back2.Image = "http://www.roblox.com/asset/?id=" .. (images[two])
end
end)
if err2 then
change2()
end
end
while true do
print("image 1 live")
wait(5)
for i= 1,10,1 do
back1.ImageTransparency = back1.ImageTransparency + 0.1
back2.ImageTransparency = back2.ImageTransparency - 0.1
wait(0.1)
end
print("image 2 live")
local one = one + 2
local two = two + 2
change1()
wait(5)
for i= 1,10,1 do
back1.ImageTransparency = back1.ImageTransparency - 0.1
back2.ImageTransparency = back2.ImageTransparency + 0.1
wait(0.1)
end
local one = one + 2
local two = two + 2
change2()
end
Even with trying to use a pcall to fix it. The trial images I selected won't appear correctly. Please play the game to see for yourself.
It would be much appreciated if you could share any suggestions you have to this problem.

3 comments
Edit:- please use text for links
why are you using a server script in a GUI
Good point. I will make it a local script. But it hasn't affected the problem though.