Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 14 Dec 2012 04:29 PM |
I got myself suck in a pit. MY script is full of for, statement to add remove add remove-
I need this script block-- inside of a bigger script that works to REMOVE anything that is inside of the giver scripts out of the player Backpack so they can not get more than one item
please help
originals = script.Parent.Parent.Parent:getChildren() for w = 1, #originals do if originals[w].className == "TextButton" then toolitems = originals[w].Wep.Givetool:GetChildren() for a = 1, #toolitems do toolitemlist = toolitems[a].Name if (player.Backpack.toolitemlist ~= nil) player.Backpack.toolitemlist:Destory() end end end end |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 14 Dec 2012 04:32 PM |
| So, if they have more than one item, you want all but one deleted? |
|
|
| Report Abuse |
|
|
Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 14 Dec 2012 04:42 PM |
No- its really complicated. There are three types of weapons special secondary and prime
a player can have ONE of each
the problem is if a player switches a weapon i need to make it so it only gets rid of items that are from its type and not get rid of a prime weapon- or every weapon.
im trying to do this by getting the names of every tool and if the tool is also in the backpack but not the current tool then it will be deleted
|
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 14 Dec 2012 04:44 PM |
| Okay, not to sure how else to do so. |
|
|
| Report Abuse |
|
|
Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 14 Dec 2012 04:46 PM |
-- Currently
tooltype = script.Parent.Parent.Parent:getChildren() for b = 1, #tooltype do if tooltype[b].className == "TextButton" then toolitems = tooltype[b].Wep.Givetool:GetChildren() for a = 1, #toolitems do toolitemlist = toolitems[a].Name if (player.Backpack.toolitemlist ~= nil) then -- 30 player.Backpack.toolitemlist:Destory() end end end end
-- error line 30 |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 14 Dec 2012 04:49 PM |
--change line 30 to if player.Backpack:findFirstChild("toolitemlist") then |
|
|
| Report Abuse |
|
|
Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 14 Dec 2012 05:01 PM |
it says toolitems = tooltype[b].Wep.Givetool:GetChildren()
-- is not a valid member of image button
although The script is place in the button so i do not see why it says this |
|
|
| Report Abuse |
|
|
Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 14 Dec 2012 05:15 PM |
i think i see the problem
i change it to this
itemnames = script.Parent.Parent.Parent.Itemlist:getChildren() for b = 1, #itemnames do iname[b] = itemnames[b].Name isearch = player.Backpack:getChildren() for a = 1, #isearch do if isearch[a].Name == iname then isearch:Destory() end end
|
|
|
| Report Abuse |
|
|
|
| 14 Dec 2012 05:19 PM |
You didn't do isearch[a] and spelled destroy wrong. Try this:
local ItemNames = script.Parent.Parent.Parent.Itemlist:GetChildren() for i, v in pairs(ItemNames) do local BackPackNames = player.Backpack:GetChildren() for a, b in pairs(BackPackNames) do if v.Name == b.Name then b:Destroy() end end end
Maybe?
¤ † KMXD† ¤
|
|
|
| Report Abuse |
|
|