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 make a script that removes weapons

Previous Thread :: Next Thread 
Draunamou is not online. 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
InsaneMisfit is not online. InsaneMisfit
Joined: 16 Sep 2011
Total Posts: 8534
16 Feb 2014 11:38 AM
1. You can't "touch" a script
Report Abuse
Draunamou is not online. 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 is not online. 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 is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. Draunamou
Joined: 02 Nov 2013
Total Posts: 2071
16 Feb 2014 11:45 AM
@King Thanks :D
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 11:45 AM
sorry,but I LOVE making simple scripts like that:)
Report Abuse
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
16 Feb 2014 11:46 AM
no problem
Report Abuse
KingJacko is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
16 Feb 2014 11:48 AM
Jack, you do not know how to script.
Report Abuse
SFOH is not online. 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 is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. Draunamou
Joined: 02 Nov 2013
Total Posts: 2071
16 Feb 2014 11:58 AM
Thanks to everyone who contributed!
Report Abuse
SFOH is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 12:04 PM
lol,my answer is perfect,100%
it works,and works EXACTLY how he wanted it
Report Abuse
Draunamou is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 12:12 PM
oh well then youd just edit it a little,i gtg:(
Report Abuse
Draunamou is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
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