Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question