An issue I'm having with GUI icons

I am currently developing a FNaF AR inspired Roblox game, I’m having major issues with GUI icons.
Basically, there’s a menu in the game where you can assemble animatronics using the suits and CPUs unlocked from fighting said animatronics - but it seems to be causing issues with the icons.
The only issue I’m having with this is that all the icons are being swapped out for one specific icon (being Freddy’s, the way I want it to be is that depending on the save data value it’ll change that specific slot’s icon to that data value, but it does this strange behaviour where it only applies one single character’s icon to all icon, instead of just one)

image

function workshopIconsRefresh()
	for i, image in pairs(GUI.Workshop.ScrollingFrame:GetChildren()) do
		for i, data in pairs(player["Save Data"].Workshop:GetDescendants()) do
			if image:IsA("ImageButton") then
				if data:IsA"StringValue" and data.Name == "Suit" then
					image.Image = AnimatronicInfo[data.Value]["Items"]["SuitImage"]
				end
			end
		end
	end
end

Any help would be much appreciated.

Where is the script located and is it local or Server?

1 Like

Are the SuitImages different?

Nice nice

1 Like

Local - as it is a GUI script.

Yep, here’s all 3 I have so far. (Need to render out the rest, with models by me)
image
image
image

1 Like

Im suspecting that when you leave, the images get saved but it seems that you are only setting one of the images on line 6.

1 Like

Those look lovely btw :heart:

:))

1 Like

They are very good! Very clean and looks like theyre from a canon game.

1 Like

You set all of the images but never check whether the image is corresponding to the imagebutton.

1 Like

How so? The images are set through the string values of the save data, which the strings are names of the characters, it then pulls the image IDs out of a module.
image

I’m not sure if this was the wrong way to go or not.

How exactly should I make this change?

Assuming the imagebutton has the same name as the value from the data from this line

I would assume like this:

function workshopIconsRefresh()
	for i, image in pairs(GUI.Workshop.ScrollingFrame:GetChildren()) do
		for i, data in pairs(player["Save Data"].Workshop:GetDescendants()) do
			if image:IsA("ImageButton") then
				if data:IsA("StringValue") and data.Name == "Suit" and data.Value == image.Name then
					image.Image = AnimatronicInfo[data.Value]["Items"]["SuitImage"]
				end
			end
		end
	end
end

If that’s not the case, could I see the explorer of the image buttons and the data values?

1 Like

Thats kinda weird… i put it in my own game but its a photo of chica but the error is full of Freddy???

do you have any other scripts?

image
Weirdly enough, it pulls only images of Chica now.


image
The way I have it setup for beta testing purposes is that Odd numbers pull Freddy and even pull Chica to make sure it works - but it seems all of them pull Chica only.

Is there some sort of value inside of the ImageButtons that allow you to determine which animatronic it is meant to be? Actually, since I have just read the text below the images, this is what it should be:

function workshopIconsRefresh()
	for i, image in pairs(GUI.Workshop.ScrollingFrame:GetChildren()) do
		if image:IsA("ImageButton") then
			image.Image = AnimatronicInfo[player["Save Data"].Workshop:FindFirstChild(image.Name).Suit.Value]["Items"]["SuitImage"]
		end
	end
end
1 Like

Nope, the way I set it up is that it just pulls it from the save data, should I change this to make it change values inside the imagebuttons to the save data and THEN change the image to those values?

Yeah, I just read the sentence and properly looked at the images, so it would be this

(I had edited my post)

1 Like

You’re completely correct - forgot about the :FindFirstChild function, thank you so much.

Thank you MyDeadUser and Probloxed123 as well! You all are very kind - I wish you three well on your future endeavors!