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

Inventory organizer isn't working, linked script. What can I do tho fix or remake to work?

Asked by 7 years ago

At the moment I have a Gui that has 25 slots for items (ImageButtons). There is a script inside the items you pick up that changes the next slot available out of the 25 slots. The problem Im having is when you drop an item it wont fill in the spaces... For example, lets say I pick of 5 different items, that would mean the the first 5 slots are filled. Then lest say I drop the 3rd item which then the script is supposed to move the 4th and 5th item to the 3rd and 4th slot but its not doing so. I was wondering if someone could take a look and give me some advice on what to do hints why I am here.

script inside the items>>>

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    local items = Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory
    for i = 1, 25 do 
        local itm = items:FindFirstChild('Item' .. tostring(i)) 
        if itm.ItemNumber.Value == 0 then
            itm.ItemNumber.Value = script.Parent.ItemId.Value
            itm.Image = script.Parent.PicId.Value
                   break
        end
    end
end)

LINKED!!! Script inside ImageButtons>>>


wait(.8) local Player = game.Players.LocalPlayer local Gui = script.Parent local Observing = script.Observer.Value local Item = script.Parent.ItemNumber local Pic = script.Parent.Image script.Observer.Value.ItemNumber.Changed:connect(function() if script.Observer.Value.ItemNumber.Value == 0 then Item.Value = 0 Observing.ItemNumber.Value = Item.Value Observing.Image = Pic Pic = "" end end)
3
Just an idea - ROBLOX has a few handy, just released, UI constraints. This includes grid and list layout constraints, which automatically sort objects into an inventory style. Try it out - make a frame, put a couple of frames inside it, then insert the constraint. TheDeadlyPanther 2460 — 7y
0
Also adding onto that, if you still want to preset the ImageButtons and put 25 in the gui, if you make 'Visible' false, it doesn't include it in the UI constraint, and fills in the space. climethestair 1663 — 6y

Answer this question