|
| 17 May 2015 01:42 AM |
Hey there! I was wondering how I could restrict a Weapon Giver so that if the player has 2 weapons/tools or more, the giver wouldn't do anything! Or maybe even better: as the title says: how can you restrict a player to have only 2 tools/weapons?
The reason is I use many guns based on TurboFusions gun kit, this combined with a Tycoon would lag so much that the bricks would go slowmo
Thanks in advance! |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 01:46 AM |
you would do something like function onTouch(hit) h = hit.Parent:getPlayerFromCharacter() b = h.Backpack:GetChildren() if #b > 2 then else --your giver script thing here |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 02:06 AM |
Hah, looks like I destroyed it! :'D Thanks for the fast reply, however, I think I pasted it wrongly, here's the entire giver script right now.
local debounce = false
function onTouch(hit) local h = hit.Parent:getPlayerFromCharacter() local b = h.Backpack:GetChildren() if #b > 2 then
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #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
game.Lighting.LAR08:clone().Parent = player.Backpack
wait(5) debounce = false else end end
|
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 17 May 2015 04:58 AM |
wait() game.Players.LocalPlayer:WaitForChild("Backpack").ChildAdded:connect(function(ins) if #game.Players.LocalPlayer:WaitForChild("Backpack"):GetChildren() > 2 then ins:Destroy() end end) |
|
|
| Report Abuse |
|
|