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)

3 comments

0

you should change the elseif to just "else" and add nothing more after that

0

Do all the frames have a Filled BoolValue object?

0

yes