My While True Do loop is not working

So I am creating pixelated sprites (the bit characters like old 1985 super mario, not the soda) inside roblox. I tried to create an idle animation using the while true do to loop 2 decals. Here’s the script (which didn’t work):

while true do
	script.Parent.Image = "rbxassetid://7437583918"
	wait(0.1)
	script.Parent.Image = "rbxassetid://7437539524"
	wait(0.1)
end

Ask me questions if you don’t seem to understand mine or you need clarifications about the problem.
Edit: For those asking, this is how the script is placed (might help):
image

There’s not enough context here. If a script isn’t working, consider applying basic debugging strategies first so you can provide a better explanation of the problem. The console is great to narrow down problems whether it’s because your script is throwing an error or because it’s actually not running.

The code doesn’t look incorrect so I assume it’s a problem with the setup but without knowing anything in that regard and only being told “this doesn’t work” it’s hard to offer you any kind of solution. You could share your hierarchy, the script type or any other details that might help. Be descriptive.

2 Likes

if you change images id it will do not work try to Instance.new ImageLable with new id

1 Like
while true do
	l = script.Parent ---- change this to the parent you want image be in
	a = Instance.new("ImageLabel")
	a.Size = UDim2.new(0,100,0,100)
	a.Position = UDim2.new(0.404,0,0.364,0)
	a.Image = "rbxassetid://7437583918"
	a.Parent = l
	wait(1)
	a:Destroy()
	v = Instance.new("ImageLabel")
	a.Size = UDim2.new(0,100,0,100)
	a.Position = UDim2.new(0.404,0,0.364,0)
	v.Image = "rbxassetid://7437539524"
	v.Parent = l
	wait(1)
	v:Destroy()
end

dont forget to change the size and position
try this it may work

The script is a local script and not a normal script.

try my script lol it will work fine am sure

1 Like

That’s not enough context so I still can’t help you. Vague answers may only net complicated or unnecessary answers like the above which suggests instancing new ImageLabels instead and that changing the image doesn’t work, which is both incorrect and bad to do.

In the meantime, check if your LocalScript is in a place where it’s allowed to execute.

1 Like

Tried it, still didn’t work. I tried to edit the script too.

Are there any errors? Is there anything before the loop thats yielding or pausing the thread? How exactly isn’t it working?

Try adding a print at the start of the script andr in the loop to see if its even running.

1 Like

No, there are no errors in the output.

Just realised there is this infinite yield in the output. Sorry about that, didn’t check it before.

The loop doesn’t work and it doesn’t change the decal.

Try changing the wait value to like say 1 sec

I did manage to make it work but not in the starter character but in the workspace which defeats the purpose of using it as a custom character.