|
| 15 Jun 2015 08:23 AM |
v is the player, tools is a table with tool names
it doesnt work
BUT IT HAS TO BE PUT IN PLAYER SO I CAN GIVE THEM BACK
if TakeTools == true then for _,vv in ipairs(v.Backpack:GetChildren()) do for _,vvv in ipairs(Tools) do for _,vvvv in ipairs(v.Character:GetChildren()) do if vv.Name == vvv then vv.Parent = v elseif vvvv.Name == vvv then vv.Parent = v end end end end end |
|
|
| Report Abuse |
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 15 Jun 2015 08:31 AM |
Your loops are confusing. You don't need to do it like that. Also your variable names are confusing.
local takeToolsFromContainer = function (tools, player, container) if (container == nil) then return; end for _, obj in pairs(container:GetChildren()) do for _, tool in pairs(tools) do if (obj.Name == tool) then obj.Parent = player; end end end end;
local takeTools = function (tools, player) takeToolsFromContainer(tools, player, player.Backpack); takeToolsFromContainer(tools, player, player.Character); end; |
|
|
| Report Abuse |
|
|
| 15 Jun 2015 08:51 AM |
| Thanks droid. Would you like to see my finished code? |
|
|
| Report Abuse |
|