Why do my image button image isn't updating

Hello !
To make a customizable background, I’m trying to replace the default background by the id that the player wrote, the problem is that it isn’t updating via the script, but when I do it manually, it works perfectly fine… Can you help me? Script :

script.Parent.FocusLost:Connect(function(enterPressed)
	local bg = script.Parent.Parent.ImageButton
	bg.BackgroundTransparency = 1
	bg.ImageTransparency = 0
	bg.Image = ""
	wait()
	bg.Image = "rbxassetid://".. script.Parent.Text
end)	

What’s with that random wait() in there? It might have to do with your problem.

When I did the manual test, I saw that when I replace the image value with nothing, then when I paste the correct id, it works, so I thought it was cuz of an order or something

Try removing that wait() if it’s not going to have a value.

Change

bg.Image = "rbxassetid://".. script.Parent.Text

To this?

bg.Image = "rbxthumb://type=Asset&id="..script.Parent.Text.."&w=150&h=150"

Could be you’re inserting a decal id instead of an image id. It works manually probably because studio converts it for you but from a script it doesnt

2 Likes

Already tried before, and it didn’t fix my issue

It doesn’t either (for for the late response I was focused on the creating file part ^^')
– Edit –
Nvm, I came back to my script and It uploaded