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
 

Detecting if a weapon is equipped?

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
23 Aug 2014 04:57 PM
I'm making a script to rob stores. Basically, I need to know how to detect if a weapon is equipped, as well as checking the name to make sure it is a weapon, and not just a regular tool. So if you happen to know, thanks.
Report Abuse
Legostarwars98745 is not online. Legostarwars98745
Joined: 02 Jan 2008
Total Posts: 68659
23 Aug 2014 05:09 PM
tool.Equipped:connect(function()
bla
end)
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
23 Aug 2014 05:22 PM
tool.HasBeenEquippedByParent:connect(function()
end)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
23 Aug 2014 05:23 PM
I'm trying to detect it from an invisible brick inside of all the stores.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
23 Aug 2014 05:24 PM
.Touched:connect(function(t)

if Game.Players:GetPlayerFromCharacter(t) then

local p = Game.Players:GetPlayerFormCharacter(t);

if p.HasAToolInsideOfGlobalCharacter() then

--stuff

end
end
end)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
23 Aug 2014 05:29 PM
Would I be able to use a table to make editing easier?

script.Parent.Touched:connect(function(t)

if Game.Players:GetPlayerFromCharacter(t) then

local p = Game.Players:GetPlayerFormCharacter(t);

local weps = {"Pistol"} -- etc etc

if p.HasAToolInsideOfGlobalCharacter(weps) then

--stuff

end
end
end)
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
23 Aug 2014 05:35 PM
Ok, I was trolling with the second if statement.


In a server script:

local tbl = {"Pistol"}
local prt = script.Parent;
prt.Touched:connect(function(t)

if Game.Players:GetPlayerFromCharacter(t) then

local p = Game.Players:GetPlayerFormCharacter(t);



if p.Character:FindFirstChild(tbl[1]) then

--stuff

end
end
end)
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