Billboard Image Disappears when Changed via Script

I’m trying to make a billboard image that’s attached to an enemy’s torso play a walk animation by changing the image in a script. For some reason the image is completely invisible when the script runs, and there are no errors. It doesn’t seem like a problem with the images because they work fine when manually inserted to the billboard image.

Animate script:

local imageLabel = script.Parent.Torso.BillboardGui.ImageLabel

local Idle = script.Parent.Idle
local Walk1 = script.Parent.Walk1
local Walk2 = script.Parent.Walk2

while true do
	imageLabel.Image = Walk1.Value
	
	print("walk 1, " ..imageLabel.Image)

	wait(.2)

	imageLabel.Image = Walk2.Value
	
	print("walk 2, " ..imageLabel.Image)

	wait(.2)
end
3 Likes

Maybe try to preload the images using ContentProvider?
You would basically have a LocalScript in ReplicatedFirst and it would contain this:

task.spawn(function()
    local assets = {image1,image2} -- put your images here
    local ContentProvider = game:GetService("ContentProvider")
    ContentProvider:PreloadAsync(assets)
end)
1 Like

I tried this but it didn’t change anything and there are still no errors

When changing images through scripts, the image ID value should be something like rbxassetid//id.

If your Walk1 and and Walk2 values are just IDs, you should change the script to this:

local imageLabel = script.Parent.Torso.BillboardGui.ImageLabel

local Idle = script.Parent.Idle
local Walk1 = script.Parent.Walk1
local Walk2 = script.Parent.Walk2

while true do
	imageLabel.Image = "rbxassetid//"..Walk1.Value
	
	print("walk 1, " ..imageLabel.Image)

	wait(.2)

	imageLabel.Image = "rbxassetid//"..Walk2.Value
	
	print("walk 2, " ..imageLabel.Image)

	wait(.2)
end

If this doesn’t help you, try checking if the images/decals aren’t deleted.

I tried this and it has no affect. The images are not deleted, and they work when manually inserted into the image label but not if I insert them via the script.

What is the name of the image … is it a number? If so try …

 imageLabel.Image = "rbxassetid//" .. tostring(Walk2.Value)

the image is being put into the image label just fine as shown by the output. It’s there but it doesn’t show

Maybe it’s changing too quickly and not enough time for it to load?

nope, it still doesn’t show if I make the change slower

Hmm, is it set to Visable or not checked.

yes, the image label is set to visible.

local imageLabel = script.Parent.Torso.BillboardGui.ImageLabel

local Idle = script.Parent.Idle
local Walk1 = script.Parent.Walk1
local Walk2 = script.Parent.Walk2
while true do
    task.wait(1)
	imagelabel.Image = "rbxassetid://"..tonumber(Walk1.Value)
	task.wait(1)
	imageLabel.Image = "rbxassetid://"..tonumber(Walk2.Value)
end

try this snippet.

I’ve tried using string and number values but neither work. I don’t see why a number value would need to have “tonumber” infront

ok new plan, make two image labels then change their visibility through the loop instead of changing the image id asset.

while true do
	task.wait(1)
	imagelabelWALK2.Visible = true
	imageLabelWALK1.Visible = false
	task.wait(1)
	imagelabelWALK2.Visible = false
	imageLabelWALK1.Visible = true
end

I would rather not settle for a compromise unless completely necessary. I’ve seen this same method I’m using work for others so there must be something I’m missing.

Something is wrong with your image then, I tried my snippet and it worked.

I looked up the image number and got a game, not an image … 12615198538
(from your video)

I guess I had the wrong asset ID somehow, but even after replacing them with the correct ones it still won’t work.
This is one of the images if it could be useful: https://create.roblox.com/marketplace/asset/12615201028/Jerma-Walk1-101

Also see an infinite yield error on loading …

That’s from a different object which does not affect it even when removed