|
| 10 Jul 2011 12:50 PM |
local activated = false
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if activated == true then return end print 'Touched' if human ~= nil then g=hit.Parent.Name h=game.Players:findFirstChild(g).Backpack:getChildren() activated = true if h == nil then print 'Go' script.Parent.Parent.GS.BrickColor = BrickColor.new(37) wait(3) script.Parent.Parent.GS.BrickColor = BrickColor.new(26) else print 'Stop weapon' script.Parent.Parent.GS.BrickColor = BrickColor.new(1004) script.Parent.Parent.Buzzer.Looped = true script.Parent.Parent.Buzzer:Play() wait(3) script.Parent.Parent.Buzzer.Looped = false script.Parent.Parent.Buzzer:Stop() script.Parent.Parent.GS.BrickColor = BrickColor.new(1004) activated = false end end end
script.Parent.Touched:connect(onTouched)
Notes: GS = indicator light.
The problem is that it will always return that there is something in the player's backpack when there is not. Someone help me please. Thanks |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
| |
|
| |
|
Corecii
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 687 |
|
|
| 10 Jul 2011 12:53 PM |
GetChildren never returns nil. When nothing is in an object it returns an empty table. So: if h == nil then should be: if #h <= 0 then |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 12:54 PM |
try:
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if activated == true then return end print 'Touched' if human ~= nil then g=hit.Parent.Name h=game.Players:findFirstChild(g).Backpack:getChildren() activated = true if h ~= nil then print 'Go' script.Parent.Parent.GS.BrickColor = BrickColor.new(37) wait(3) script.Parent.Parent.GS.BrickColor = BrickColor.new(26) else print 'Stop weapon' script.Parent.Parent.GS.BrickColor = BrickColor.new(1004) script.Parent.Parent.Buzzer.Looped = true script.Parent.Parent.Buzzer:Play() wait(3) script.Parent.Parent.Buzzer.Looped = false script.Parent.Parent.Buzzer:Stop() script.Parent.Parent.GS.BrickColor = BrickColor.new(1004) activated = false end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
| |
|