Dust707
|
  |
| Joined: 27 Sep 2011 |
| Total Posts: 2613 |
|
|
| 24 Oct 2014 11:41 PM |
Hi. I've been having issues with this script, I've played with my friends and you can only take one thing one time. Please help.
local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 3, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent:clone().Parent = player.Backpack
wait(5) debounce = false end end
script.Parent.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
Dust707
|
  |
| Joined: 27 Sep 2011 |
| Total Posts: 2613 |
|
| |
|
|
| 24 Oct 2014 11:50 PM |
Well one thing I noticed,
You set players to "game.Players:children()" < error
You miss used children its supposed to be game.Players:GetChildren()
local debounce = false
function getPlayer(humanoid) local players = game.Players:GetChildren() for i = 3, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent:clone().Parent = player.Backpack
wait(5) debounce = false end end
script.Parent.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 24 Oct 2014 11:57 PM |
--This should work:
DB = true script.Parent.Parent.Touched:connect(function(part) local hum = part.Parent:FindFirstChild'Humanoid' local p = game.Players:FindFirstChild(hum.Parent.Name) if hum and p and DB then DB = false script.Parent:clone().Parent = p.Backpack wait(3) DB = true end end) |
|
|
| Report Abuse |
|
|
murcury57
|
  |
| Joined: 30 Jun 2010 |
| Total Posts: 90299 |
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 25 Oct 2014 12:20 AM |
local debounce = false
function onTouch(part) if not part.Parent then return end if not debounce then debounce = true local player = game.Players:GetPlayerFromCharacter(part.Parent)
if not player then debounce = false return end
script.Parent:clone().Parent = player.Backpack
wait(5) debounce = false end end script.Parent.Parent.Touched:connect(onTouch)
Talking in third person annoys people. |
|
|
| Report Abuse |
|
|