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

How would I use i,v in pairs to direct a button to an image?

Asked by 5 years ago

So I've been making a button that will reward the player with a pet by replacing the PetID in one of their inventory slots with something other than 0. I used i,v in pairs to get all of the inventory slots. I checked if they are a frame or not so I get the right ones, and I check if they are filled or not based on the boolvalue of filled. If they turn up not filled, then the PetID is supposed to be changed to another PetID between 1,40. I have already made the script for changing the images of the slots based on their PetID property. So what would I do to fix this code in order to reward the player with a new PetID for an empty slot?

script.Parent.MouseButton1Click:Connect(function()
    for i,v in pairs(script.Parent.Parent.Inventory.InventoryScreen.Window.Handler:GetChildren()) do
        if v.ClassName == "Frame" then
            if v.Filled.Value == true then
                print("boe")
            elseif v.Filled.Value == false then
                v.SlotInfo.PetID.Value = math.random(1,40)
            end
        end
    end
end)
0
you should change the elseif to just "else" and add nothing more after that greatneil80 2647 — 5y
0
Do all the frames have a Filled BoolValue object? User#24403 69 — 5y
0
yes rhettsmith6537 109 — 5y

Answer this question