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 |
|
|
|
| 23 Aug 2014 05:09 PM |
tool.Equipped:connect(function() bla end) |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2014 05:22 PM |
tool.HasBeenEquippedByParent:connect(function() end) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|