|
| 03 Nov 2017 08:23 PM |
I've been working on this for the past few 20-30 minutes and upon clicking my object nothing happens, the output doesn't even show any errors.
Code:
slot = game.Players.LocalPlayer.PlayerGui.Inventory.Frame
function onClicked(Player) while true do if slot.Slot1.InUse == false then slot.Slot1.InUse = true slot.Slot1.ID = 1 elseif slot.Slot1.InUse == true then if slot.Slot2.InUse == false then slot.Slot2.InUse = true slot.Slot2.ID = 1 elseif slot.Slot2.InUse == true then if slot.Slot3.InUse == false then slot.Slot3.InUse = true slot.Slot3.ID = 1 elseif slot.Slot3.InUse == true then if slot.Slot4.InUse == false then slot.Slot4.InUse = true slot.Slot4.ID = 1 elseif slot.Slot4.InUse == true then if slot.Slot5.InUse == false then slot.Slot5.InUse = true slot.Slot5.ID = 1 elseif slot.Slot5.InUse == true then if slot.Slot6.InUse == false then slot.Slot6.InUse = true slot.Slot6.ID = 1 elseif slot.Slot6.InUse == true then if slot.Slot7.InUse == false then slot.Slot7.InUse = true slot.Slot7.ID = 1 elseif slot.Slot7.InUse == true then if slot.Slot8.InUse == false then slot.Slot8.InUse = true slot.Slot8.ID = 1 elseif slot.Slot8.InUse == true then if slot.Slot9.InUse == false then slot.Slot9.InUse = true slot.Slot9.ID = 1 elseif slot.Slot9.InUse == true then if slot.Slot10.InUse == false then slot.Slot10.InUse = true slot.Slot10.ID = 1 end end end end end end end end end end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 03 Nov 2017 08:29 PM |
| Is this a contemporary art exhibition or Lua..? |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 08:30 PM |
| Supposed to be an inventory system xD |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 03 Nov 2017 08:33 PM |
| I'm having struggles being helpful because of the structure. Why exactly am I seeing a loop without wait for one mouseclick? |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 08:36 PM |
| well i tried using what I knew with checks and such, i probably wasn't supposed to put every single slot check in one script or something in that same matter. Any idea on what I could do? if you don't know i'm trying to create a script in which when the when player clicks on an object they pick it up in their inventory after it checks through to see if there is any available slot, and another script will display an image depending on the ID. |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 03 Nov 2017 08:53 PM |
Well you could for instance make a table of slots, setting their value to whatever is in the slot if it's filled.
slots = {} for i = 1,numberofslots do slots[i] = {nil,nil} -- or any other table with placeholder values declaring it's empty end
then on click you loop through all slots again and when you find one that's empty you put the item data in that slot
|
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 09:08 PM |
| So if i understand i would do something such as Slots = ### ## ## ## ## ## ## ## ## ### for i = 1,numberofslots do slots[i] = {nil,nil} -- or any other table with placeholder values declaring it's empty end ? |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 09:11 PM |
slots = game.Players.LocalPlayer.PlayerGui.Inventory.Frame
function onClicked(Player) while true do slots = {} -- but what would i place here? for i = 1,10 do slots[i] = {nil,nil} -- or any other table with placeholder values declaring it's empty end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 09:15 PM |
| Why do you need a loop for this again? |
|
|
| Report Abuse |
|
|
|
| 03 Nov 2017 09:16 PM |
| its an inventory system i'm trying to create that loop checks to see if any slots are available for the item to be in. |
|
|
| Report Abuse |
|
|