generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do I remove tools when a player touches a brick?

Previous Thread :: Next Thread 
peaspod is not online. peaspod
Joined: 29 Sep 2010
Total Posts: 2809
03 Nov 2012 04:15 PM
I have this but it doesn't work:

function onTouched(hit)
tools = hit.BackPack:GetChildren()
for i = 1,#tools do
tools[i]:Remove()
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
03 Nov 2012 04:18 PM
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
tools = hit.Parent.Backpack:GetChildren()
for i = 1,#tools do
tools[i]:Remove()
end
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
03 Nov 2012 04:23 PM
function onTouched(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
player = game.Players:GetPlayerFromCharacter(hit.Parent)
tools = player.Backpack:GetChildren()
for i = 1,#tools do
tools[i]:Remove()
end
end
end
script.Parent.Touched:connect(onTouched)

I believe.
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
03 Nov 2012 04:28 PM
function onTouch(hit)
character = hit.Parent
if game:GetService("Players"):GetPlayerFromCharacter(character) then
player = game:GetService("Players"):GetPlayerFromCharacter(character)
tools = player.Backpack
for _,a in pairs(tools) do
if a:IsA("Tool") or a:IsA("HopperBin") then
a:remove()
end
end
end
end

Basically what Monkey put.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image