of     1   

Seranok
#85527814Friday, December 28, 2012 7:53 PM GMT

When the user presses backspace, I want to remove the currently equipped gear if any. First I tried this:     player:GetMouse().KeyDown:connect(function(key)         if string.byte(key) == 8 then             -- backspace key was pressed             for _, child in pairs(player.Character:GetChildren()) do                 if child.ClassName == "Tool" then                     child:Destroy()                 end             end         end     end) But that didn't work because the tool had already been moved by the time my listener was called. I could do this:     player.Backpack.ChildRemoved:connect(function(child)         wait()         if child.Parent == Workspace then             child:Destroy()         end     end) Are there any better solutions, preferably that don't use wait or tick?
BJDyer
#85528203Friday, December 28, 2012 7:57 PM GMT

That's the only one I know. Technically I should have 18k posts and i'm BD/Gatorfan1
eJorge
#85528580Friday, December 28, 2012 8:02 PM GMT

Why don't you use a ChildAdded event on workspace? workspace.ChildAdded:connect(function(child)      if child:IsA("Tool") then           child:Destroy()      end end)
belial52
#85529220Friday, December 28, 2012 8:09 PM GMT

Actually, your second one would only fire once and wouldn't remove it once it entered the workspace simply because tools are removed from your backpack and put into your character when you use them.
UnAdmin
#85532031Friday, December 28, 2012 8:39 PM GMT

Is Scripting Helpers down? ~I love to trade! Send me trade requests!~
rcm
#85532519Friday, December 28, 2012 8:44 PM GMT

Why not just set the .CanBeDropped property to false?
Seranok
#85537124Friday, December 28, 2012 9:36 PM GMT

> Why not just set the .CanBeDropped property to false? Because then the tool is moved to the backpack, instead of being removed altogether.
Voidacity
#85538472Friday, December 28, 2012 9:51 PM GMT

[ Content Deleted ]
FreeToTake
#85541890Friday, December 28, 2012 10:29 PM GMT

workspace.ChildAdded:connect(function(x) if x:IsA("Tool") or x:IsA("HopperBin") then x:Destroy() end end)
SourceOfEvil
#85542930Friday, December 28, 2012 10:41 PM GMT

game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(function(char) char.ChildAdded:connect(function(child) if child:IsA("Tool") then plyr:GetMouse().KeyDown:connect(function(key) if key:byte() == 8 and child and plyr.Backpack:FindFirstChild(child.Name) then child:Destroy() end end) end end) end) end) Something like that?
iiWishez
#123793591Wednesday, January 22, 2014 10:26 PM GMT

thanks your script worked for me c: FreeToTake
XML1
#123796586Wednesday, January 22, 2014 10:56 PM GMT

I don't know if you consider this hacky but use a hopperbin and weld anything to the player for the tool part. (unless you need tool-specific methods, hopperbins are the best because they stay selected when you press backspack)
SCARFACIAL
#123804601Thursday, January 23, 2014 12:22 AM GMT

Set CanBeDropped to false and use a modified version of your first example?

    of     1