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 » Scripters
Home Search
 

Re: How to restrict inventory to 2 slots?

Previous Thread :: Next Thread 
FallenAngel1733 is not online. FallenAngel1733
Joined: 29 Nov 2008
Total Posts: 10
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
CrimsonForce is not online. CrimsonForce
Joined: 11 Sep 2010
Total Posts: 35714
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
FallenAngel1733 is not online. FallenAngel1733
Joined: 29 Nov 2008
Total Posts: 10
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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