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 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 all ImageButtons that supposed to move the items up the chain:
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)
No I have not made the dropping script yet.
Try implement this. Its hard to help specifically without the whole hierarchy and everything. But you should get the general idea of what needs to be done here.
game.Players.PlayerAdded:connect(function(player) -- Get the LP this way so we can still access all that playergui stuff from workspace local items = player.PlayerGui.InventoryGui.Frame.Inventory.Inventory --<<edit these paths>>, remember "player" is now the local player, so if you do player.PlayerGui, thats where everything copied from StarterGui will be local Gui = script.Parent Observing = script.Observer.Value Item = script.Parent.ItemNumber Pic = script.Parent.Image script.Parent.ClickDetector.MouseClick:connect(function(Player) 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 script.Observer.Value.ItemNumber.Changed:connect(function() --again, change path for anything here if script.Observer.Value.ItemNumber.Value == 0 then --get index of blank space for i = index, i < #items do --from the index to the end of the array, --we will be bumping items over to move that blank space to the end of the array so it doesn't exist items[i] = items[i+1] --set blank space to next item in list and repeat so all items shift down the list end --reset the list, maybe make the above block a function so you can call it to "refresh" the gui whenever something changes --Much of this above is just sort of an example since I don't know your hierarchy that well so it will need some tweaking. end end) end)