Here is a script I created, and the images never change. I used print statements to make sure the if end was working properly, and it does.
if difference >= 5 then
if difference >= 20 then
if difference >= 100 then
image = listOfIds[4]
else
image = listOfIds[3]
end
else
image = listOfIds[2]
end
else
image = listOfIds[1]
end
Below is 'ListOfIds"
local listOfIds = {
"rbxassetid://7456445734",
"rbxassetid://7459708647",
"rbxassetid://7459706335",
"rbxassetid://7459697091",
}
local Images = {} -- Table of images
local ContentProvider = game:GetService("ContentProvider")
local ImagesLeft = #Images
ContentProvider:PreloadAsync(Images, function()
ImagesLeft = ImagesLeft - 1
end)
if ImagesLeft == 0 then
-- Code
end
You did local image = animator.Image which saves the current image of the animator in a variable. If you wanted to change the image, then you would have to change the .Image of the animator. Changing local image would just save a different number/variable instead to that variable.
Yes, # returns the length of indexs in a list. However, this does not include anything other than integers. So local tab = {"Hi", "Pie", [3] = "Apple"} print(#tab) would print 3 whereas local tab = {Apple = true, [1.5] = "pie", ["Workspace"] = 2} print(#tab) would print 0
table.getn() does exactly the same thing as # but slower.