Issue with my script?

Just trying to loop through some images for my GUI here. But it gives me this error:
03:05:39.546 Unable to assign property Image. Content expected, got nil - Client - LocalScript:27

cycleImages = {
	img1 = "http://www.roblox.com/asset/?id=11112076930", 
	img2 = "http://www.roblox.com/asset/?id=11112076930", 
	img3 = "http://www.roblox.com/asset/?id=11112077780", 
	img4 = "http://www.roblox.com/asset/?id=11112078096", 
	img5 = "http://www.roblox.com/asset/?id=11112078422", 
	img6 = "http://www.roblox.com/asset/?id=11112078720", 
	img7 = "http://www.roblox.com/asset/?id=11112079023", 
	img8 = "http://www.roblox.com/asset/?id=11112079410", 
	img9 = "http://www.roblox.com/asset/?id=11112079793", 
	img10 = "http://www.roblox.com/asset/?id=11112080150"	
}

local menu = script.Parent:WaitForChild("BackgroundFrame")
local playButton = menu:WaitForChild("Newgame")
local playButtonBackgroundFrame = menu:WaitForChild("Button1Background")
local isHovering
playButton.MouseEnter:Connect(function()
	isHovering = true
	playButtonBackgroundFrame.Visible = true
	playButton.BackgroundTransparency = 1
	while isHovering do
		for i = 1,10,1 do
			playButtonBackgroundFrame.Image = cycleImages[i] -- Line 27 error
			task.wait()
		end
		task.wait()
	end
end)

Your using a dictionary to store your images not an array.
Easiest fix is to remove the img1= etc from your dictionary which will change it to a regular array for the loop to process.

cycleImages = {
	"http://www.roblox.com/asset/?id=11112076930", 
	"http://www.roblox.com/asset/?id=11112076930", 
	"http://www.roblox.com/asset/?id=11112077780", 
	"http://www.roblox.com/asset/?id=11112078096", 
	"http://www.roblox.com/asset/?id=11112078422", 
	"http://www.roblox.com/asset/?id=11112078720", 
	"http://www.roblox.com/asset/?id=11112079023", 
	"http://www.roblox.com/asset/?id=11112079410", 
	 "http://www.roblox.com/asset/?id=11112079793", 
	"http://www.roblox.com/asset/?id=11112080150"	
}
1 Like