|
| 28 Jun 2014 10:29 PM |
inventory = {} maxItems = 15 -- change this to how many items you can store currentItems = #inventory
function addItem(x) currentItems = #inventory if (currentItems < maxItems) then local item = table.insert(inventory, (currentItems + 1), x) print(x.. ' added') currentItems = #inventory local g = script.Parent.Inventory:GetChildren() local objec = game.Lighting:FindFirstChild(x) local object = objec:clone() for i = 1, #g do if (g[i].Name == (currentItems + 1)) then g[i].Text.Text = object.Name object.Parent = script.Parent.Backpack break end end else print('Inventory full') end end
addItem("Sword")
--No output |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:34 PM |
| I have "Sword" in Lighting. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:40 PM |
| Come on. Please answer. Don't be shy. |
|
|
| Report Abuse |
|
|
| |
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 10:48 PM |
inventory = {} maxItems = 15 -- change this to how many items you can store currentItems = #inventory
function addItem(x) currentItems = #inventory if (currentItems < maxItems) then local item = table.insert(inventory, (currentItems + 1), x) print(x.. ' added') currentItems = #inventory local g = script.Parent.Inventory:GetChildren() local objec = game.Lighting:FindFirstChild(x) local object = objec:clone() --- You forgot the t in object. for i = 1, #g do if (g[i].Name == (currentItems + 1)) then g[i].Text.Text = object.Name object.Parent = script.Parent.Backpack break end end else print('Inventory full') end end
addItem("Sword") |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:49 PM |
local objec = game.Lighting:FindFirstChild(x) local object = objec:clone() --- You forgot the t in object. Nope |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 10:49 PM |
owaitno
That's a variable, my bad. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:50 PM |
| I don't get it either, lol. I used some real hacky stuff here. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 10:52 PM |
inventory = {} maxItems = 15 -- change this to how many items you can store currentItems = #inventory
function addItem(x) currentItems = #inventory -- Well, it seems you are calling the number of items, and not the items in the table, or atleast, that's what i've been taught/learned.
if (currentItems < maxItems) then local item = table.insert(inventory, (currentItems + 1), x) print(x.. ' added') currentItems = #inventory local g = script.Parent.Inventory:GetChildren() local objec = game.Lighting:FindFirstChild(x) local object = objec:clone() for i = 1, #g do if (g[i].Name == (currentItems + 1)) then g[i].Text.Text = object.Name object.Parent = script.Parent.Backpack break end end else print('Inventory full') end end
addItem("Sword") |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:54 PM |
| Well that's on purpose. It's kind of complicated. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:56 PM |
If you need the model, I can give it to you, I was gonna make it open source anyway
|
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 10:58 PM |
http://www.roblox.com/GUI-Inventory-System-item?id=163734799
check it out. |
|
|
| Report Abuse |
|
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 11:00 PM |
| Let me just say; it looks marvelous. |
|
|
| Report Abuse |
|
|
| |
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 11:01 PM |
Your probably did it on purpose, but you have
inventory = {} maxItems = 15 -- change this to how many items you can store currentItems = #inventory
twice in the script. |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Jun 2014 11:04 PM |
| I must've added that at the last minute. And that didn't fix it :( |
|
|
| Report Abuse |
|
|
| |
|
Krosskode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 11001 |
|
|
| 28 Jun 2014 11:14 PM |
| I'm trying to figure out why it won't work; it looks perfectly fine. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 11:18 PM |
I found one error:
local g = script.Parent.Inventory:GetChildren() Instead of: local g = script.Parent.Inventory.Holder_1:GetChildren()
Still won't work. Hmmm. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 11:20 PM |
| I wish oysi was online. He/she would snap this in a matter of seconds. :( |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 11:43 PM |
This is what I have so far:
inventory = {} maxItems = 15 -- change this to how many items you can store currentItems = #inventory
function addItem(x) currentItems = #inventory if (currentItems < maxItems) then local item = table.insert(inventory, (currentItems + 1), x) print(x.. ' added') currentItems = #inventory local g = script.Parent.Inventory.Holder_1:GetChildren() local objec = game.Lighting:FindFirstChild(x) local object = objec:clone() for i = 1, #g do if (g[i].Name == (currentItems + 1)) then g[i].Text.Text = object.Name object.Parent = script.Parent.Backpack break end end else print('Inventory full') end end
function removeItem(y) currentItems = #inventory if (currentItems < 1) then print('Nothing to remove') else for i = 1, #inventory do if inventory[i] == y then table.remove(inventory, i) print(y.. ' removed') break end end currentItems = #inventory end end
addItem("Sword")
|
|
|
| Report Abuse |
|
|
| |
|