Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
|
| 16 Feb 2014 11:37 AM |
| How do I make a script that removes someone's weapons when they touch it? |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:38 AM |
| 1. You can't "touch" a script |
|
|
| Report Abuse |
|
|
Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
|
| 16 Feb 2014 11:39 AM |
| Sorry, I meant when they touch a brick with the script in it. |
|
|
| Report Abuse |
|
|
SFOH
|
  |
| Joined: 01 Nov 2009 |
| Total Posts: 293 |
|
|
| 16 Feb 2014 11:43 AM |
check if part touching's parent is a model check if that model has a humanoid check if game.Players:GetPlayerFromCharacter() remove tools in backpack remove tool if found in character |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 16 Feb 2014 11:44 AM |
function OnTouched() PUTPATHTOTHETOOLHERE:remove() end script.Parent.Touched:connect(OnTouched) |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:45 AM |
this is so easy,but so fun :)
function stealweps(hit) if hit.Parent:FindFirstChild("Humanoid")~=nil then for I,thing in pairs(hit.Parent:GetChildren()) do if thing:IsA ("Tool") or thing:IsA ("HopperBin") then thing:destroy() end end plr = game.Players:FindFirstChild(""..hit.Parent.Name.."") if plr~=nil then plr.Backpack:ClearAllChildren() end end end
script.Parent.Touched:connect(stealweps) |
|
|
| Report Abuse |
|
|
Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
| |
|
|
| 16 Feb 2014 11:45 AM |
| sorry,but I LOVE making simple scripts like that:) |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:46 AM |
Very easy...
function onTouched(hit) local p = game.Players:GetPlayerFromCharacter(hit.Parent) local x = p.Backpack:FindFirstChild("WEAPONNAMEHERE") if x then x:remove() end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
| |
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 16 Feb 2014 11:47 AM |
| i liek how all the people are making up such complex scripts when it really only has to be 2 and a half lines of code! |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:48 AM |
| Jack, you do not know how to script. |
|
|
| Report Abuse |
|
|
SFOH
|
  |
| Joined: 01 Nov 2009 |
| Total Posts: 293 |
|
|
| 16 Feb 2014 11:49 AM |
@island y u be stealin meh code lul |
|
|
| Report Abuse |
|
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 16 Feb 2014 11:49 AM |
| oh yrah you also need to find the player... forgot about that |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:51 AM |
lol with my script:(checklist) -checks for hopperbins or tools -checks in the players backpack and the character -is awesome check,check,and double check |
|
|
| Report Abuse |
|
|
SFOH
|
  |
| Joined: 01 Nov 2009 |
| Total Posts: 293 |
|
|
| 16 Feb 2014 11:52 AM |
| Crazy, if anything but a player's bodyparts hits the brick with your script in it, itll break it. Also, your script only works for one specific item IF its in the player's backpack. He could just hold it and walk through. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 11:57 AM |
Fine,
function onTouched(hit) local check = hit.Parent:findFirstChild("Humanod") local p = game.Players:GetPlayerFromCharacter(hit.Parent) local x = p.Backpack:FindFirstChild("WEAPONNAMEHERE") local gears = hit.Parent:GetChildren() if check then for i = 1,#gears do if gears[i].ClassName == "HopperBin" or gears[i].ClassName == "Tool" then gears[i]:remove() end if x then x:remove() end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
|
| 16 Feb 2014 11:58 AM |
| Thanks to everyone who contributed! |
|
|
| Report Abuse |
|
|
SFOH
|
  |
| Joined: 01 Nov 2009 |
| Total Posts: 293 |
|
|
| 16 Feb 2014 12:03 PM |
@Crazy now you forgot to remove the weapons in Backpack. You make me as a scripter hate the community even more(Mainly because THIS HAS ALREADY BEEN ANSWERED) |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 12:04 PM |
lol,my answer is perfect,100% it works,and works EXACTLY how he wanted it |
|
|
| Report Abuse |
|
|
Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
|
| 16 Feb 2014 12:09 PM |
| @Island where do I put the name of the tool so it knows which tool to delete and not some random ball path tool of fly tool? |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 12:12 PM |
| oh well then youd just edit it a little,i gtg:( |
|
|
| Report Abuse |
|
|
Draunamou
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 2071 |
|
|
| 16 Feb 2014 12:16 PM |
| Please?! I don't know where to edit it! |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 12:22 PM |
HA JACKO LESS LINES :P
script.Parent.Touched:connect(function(hit) game.Players:GetPlayerFromCharacter(hit).Backpack:GetChildren():Destroy() end)
Actually... Did I do that right? |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2014 12:25 PM |
script.Parent.Touched:connect(function(hit) game.Players:GetPlayerFromCharacter(hit).Backpack:ClearAllChildren() end)
Of course, it will break if it ain't a player... :O ain't was auto correct for aint... Is that a word now... |
|
|
| Report Abuse |
|
|