Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Image not loading/working in StarterGUI?

I'm working on a Tower Defense game, and I want a Icon for each different tower on the Tower List UI. I've added the tower images in replicated storage where the towers are, but when I run the game, the images don't appear. I go to PlayerGUI and press enter on the Imagebutton and it works? If you could please help that would help a lot.

Here's the local script in StarterGUI.

local ReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("ReplicatedStorage_CLOUD")
local Original = script:WaitForChild("UnitSlot")
local Location = script.Parent.Frame

for UnitFolderNumber, UnitFolderObject in pairs(game.ReplicatedStorage["ReplicatedStorage_CLOUD"].Units:GetChildren()) do
	local NewSlot = Original:Clone()
	NewSlot.Parent = Location
	if UnitFolderObject:IsA("Folder") then
		for UnitLevelsNumber, UnitLevelsObject in pairs(UnitFolderObject.Levels:GetChildren()) do
			NewSlot.ChooseUnitButton.Image = UnitLevelsObject.UnitIcon.Value
			NewSlot.ChooseUnitButton.PriceTextLabel.Text = "$".. UnitLevelsObject:WaitForChild("Cost").Value
			NewSlot.ChooseUnitButton.LocalScript.Unit.Value = UnitLevelsObject.Object[UnitFolderObject.Name]
			NewSlot.ChooseUnitButton.LocalScript.Disabled = false
			break
		end
	end
end

2 comments

0

Typically the image ID used for Gui's are separate from the ones used by Decals. Pasting the ID from a decal into a gui will auto update it to the GUI's image ID, but won't do it via script. Make sure you have the GUI ID trying to display and not the Decal ID

0

@WizyTheNinja How would I do that?

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.