Unable to assign property Image. Content expected, got nil

I am trying to change ImageButton’s image url via script. But it won’t change from ServerScriptService…

There code:

local images = {
	["elephant"] = "rbxassetid://16016416136"
}

local elephant = images[1]


local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(Player)
		Player.PlayerGui:WaitForChild("QNA").AnswerGui.Frame.a1.Image = elephant
	
	end)

Please someone help, thanks.

2 Likes

Instead of images[1], try images["elephant"]. Also, make sure that you have the asset ID correct.

What… How it worked? I am so confused right now. Why images[“elephant”] worked instead of images[1]?

It’s because you did

["elephant"] = --id

Instead of

[1] = --id

To use images[1] you could do:

{
    --id
}

Or

{
    [1] = --id
}
1 Like

Thank you my friend! I got it right now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.