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

using a value to see how many visible image labels?

Asked by
pwx 1581 Moderation Voter
4 years ago

I am currently making a sort of SCP Game in and I am currently stuck on a part of code in which I hope you guys can help me with.

So, I have this, a blink bar system.

I've already done the core code in which per sound it goes down by one, here.

I basically want to get the number on Blink (x/20) and choose how many visible image labels there should be (also out of 20).

There are twenty of these image labels and I want only a certain visible at a time.

If the blink is on 15, only 15 will show. If the blink is on 2, only 2 will show - and so on.

But I wasn't sure where to start, I'm hoping you guys could help me out?

(I feel like it's something to do with :GetChildren() and counting the children with #numberOfChildren, but I wasn't very sure).

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Assuming you're trying to have images that bind with the seconds, you can give each a name 1-20. Then you can do:

for i,image in pairs(LOCATION_OF_IMAGES) do
    if image:IsA("ImageLabel") then
        if tostring(Assets.Stats.Blink.Value) == image.Name then
            -- Do something here with the specific image
            -- EXAMPLE: image.Visible = true
        else
            -- Reset the image back to its original state
        end
    end
end
0
Also note that they should be ImageLabels. If they are something else, please replace IsA("ImageLabel") with the type of the object. chexburger 358 — 4y
0
Thank you. pwx 1581 — 4y
Ad

Answer this question