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

Once I touch the mystery box it doesn't work. Someone help?

I'm making a mystery box so you can get power-ups like speed boost, health boost, and invincible boost. But when I touch the box it stops working. Here's the script.

       for i=1,5 do
			for key, image in pairs(powerups) do
			end
			gui.Icon.Image = image --When it stops working
			wait(0.2)
			end
			giveBoost(player)
	end

1 answer

Hello,

It appears that you have left the image assigner outside of your key, image loop. To fix this, we simply rearrange the code:

   for i=1,5 do
        for key, image in pairs(powerups) do
			gui.Icon.Image = image
			wait(0.2)
        end
   end
        giveBoost(player)
end

This is important because the image variable only exists within the key, image loop.

Hopefully, this helped you solve your problem!

Cheers,

Chase

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