Need Help on Image Label Randomly Changing

Hello. I’m trying to make this image label where it randomly changes airline logos.

The problem is that it only works once and the loop stops there. It didn’t work in the local script so I just placed it in a regular script in ServerScriptService. This is what’s applied:

local images = {"rbxassetid://9582458948", "rbxassetid://9582501825", "rbxassetid://9582543033"}

local image = images[math.random(1, #images)]

local success, errormessage = pcall(function()
	while wait(2) do
		script.Parent.ImageLabel.Image = image
	end
end)

if success then
	print("Image change successful!")
else
	print("Unable to change image.")
	warn(errormessage)
end

Now I added the protected call to see if the script was really working. In case you can fix this, I’ll be very appreciated for that.

There is no need to use pcalls here.

local images = {"rbxassetid://9582458948", "rbxassetid://9582501825", "rbxassetid://9582543033"}

while task.wait(2) do  
--moved it to here so it will always choose a random image
local image = images[math.random(1, #images)] 
script.Parent.ImageLabel.Image = image
end

1 Like

Thanks for your help fixing the image label. It’s running smoothly.