Limited items from model in backpack

  1. So I want the player to pick up the “random” object that they found and have it in their backpack. The random tool is randomly chosen from a model in ServerStorage. I want the player to only have 1 of the tools from the model and if they have more, it gets removed.

  2. The issue is that A) I have no clue how to do it and B) I tried but I don’t think I’m getting it.

  3. I have tried searching on it but nothing came up of what I wanted.


This is the code I have right now

local Spawner = game.Workspace.Spawner
local Players = game:GetService("Players")
local equipped = false
local Packages = game:GetService("ServerStorage").Packages:GetChildren()
local randomPackage = Packages[math.random(1,#Packages)]:Clone()

--// Main

while wait(math.random(10,20)) do
	local Packages = game:GetService("ServerStorage").Packages:GetChildren()
	randomPackage.Parent = workspace
	randomPackage.Handle.CFrame = Spawner.CFrame
end

Players.PlayerAdded:Connect(function(player)
	if player.Backpack:FindFirstChild(randomPackage) or randomPackage.equipped == true then
		print("Player already has the package")
	else
		randomPackage.Parent = player.Backpack
	end
end)

Can anyone help?

1 Like

Anybody haven’t a clue? :thinking:

probably .Touched will do? or u can use ProximityPrompts to pick up the tools :slight_smile:

Then do something like

local itemCount = player.Backpack:GetChildren()
local count = #itemCount
if count > 1 then
 warn("Whoops! Drop 1 item to pickup this tool")
else 
 -- Give the player their tool

I didn’t test it so there is a big change the script isn’t working but i hope i helped u further!

1 Like