|
| 16 Dec 2012 02:19 PM |
local PlayersService = game.Players
function weaponCheck() local character = PlayersService.localPlayer.Character:GetChildren() for i,v in pairs(character) do if v.ClassName == "Tool" then return true end end return false end
PlayersService.localPlayer.Backpack.Changed:connect(function(property) if weaponCheck() == false then local back = PlayersService.localPlayer.Backpack:GetChildren() print(property.Name) back[property].Parent = PlayersService.localPlayer.Character end end)
It's supposed to take out a tool if you put it away and there isn't another tool out but it doesn't work.
No errors |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 16 Dec 2012 02:24 PM |
for i,v in pairs(character):GetChilderen() do if v.ClassName == "Tool" then
? |
|
|
| Report Abuse |
|
|
| |
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 16 Dec 2012 02:28 PM |
| Okay nevermind. I'm an idiot ._. |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2012 02:31 PM |
Lol okay :P
So I changed the function so it connects on DecendantAdded instead of Changed now and I'm getting this error:
Players.Player1.PlayerGui.KeyScript:18: attempt to index field '?' (a nil value)
Line 18 is: back[property].Parent = PlayersService.localPlayer.Character |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 16 Dec 2012 02:32 PM |
local PlayersService = game.Players
function weaponCheck() local character = PlayersService.LocalPlayer.Character:GetChildren() for i,v in pairs(character) do if v.ClassName == "Tool" then return true end end return false end
PlayersService.LocalPlayer.Backpack.Changed:connect(function(property) if weaponCheck() == false then local back = PlayersService.LocalPlayer.Backpack:GetChildren() print(property.Name) back[property].Parent = PlayersService.LocalPlayer.Character end end)
--Make sure this is in a local script inside the player or the character of the player. |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 16 Dec 2012 02:33 PM |
| What do you want it to do? Ignore my script for now. |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2012 02:39 PM |
| It's supposed to take out a tool if you put it away and there isn't another tool out but it doesn't work. |
|
|
| Report Abuse |
|
|
| |
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 16 Dec 2012 03:11 PM |
| What do you mean "out" ? do you mean selected or what? |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2012 03:20 PM |
"It's supposed to take out a tool if you put it away and there isn't another tool out but it doesn't work."
Out = Put in their character
Put away = deselected/placed into backpack
Isn't another tool out = There isn't a tool in their character
It doesn't work = It doesn't do the above things |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 16 Dec 2012 03:44 PM |
function weaponCheck() character = game.Players.LocalPlayer.Character:GetChildren() for i,v in pairs(character) do if v.ClassName == "Tool" then return true break end end return false end
PlayersService.LocalPlayer.Backpack.ChildAdded:connect(function(child) if child.ClassName == "Tool" and weaponCheck() == false then local back = game.Players.LocalPlayer.Backpack:GetChildren() child.Parent = game.Players.LocalPlayer.Character end end)
--give that a try |
|
|
| Report Abuse |
|
|