Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[REPOST] how to make inventory less than 1 tool?

i was making this like 4 days ago, i just got an error, i dont know why, heres the example https://gyazo.com/2ededba8cb69b036fdc09d1dd9ba518e

Player Script

local backpack = game.Players.LocalPlayer:WaitForChild("Backpack")
backpack.ChildAdded:Connect(function(child)
	local childamount = #backpack:GetChildren()
	if childamount > 1 then
		for i,tool in pairs(backpack:GetChildren()) do
			if tool ~= child then
				tool.Parent = game.Workspace.Items
				tool.Handle.Position = child.Handle.Position
			end
		end
	end
end)

clickdetect script

local sp = script.Parent
local db = false
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if db == false then
		db = true
		local backpack = plr:WaitForChild("Backpack")
		local tool = game.Workspace.Items.Sword or backpack
		if tool then
			tool.Parent = backpack
		else
			tool.Parent = game.Workspace.Items
		end
	end
	db = false
end)

Thanks

1 answer

I assume you'd want something like this?

local player = game:GetService("Players").LocalPlayer
local backpack = player.Backpack

backpack.ChildAdded:Connect(function(child()
	if (#backpack:GetChildren() > 1) then
		child:Destroy()
	end
end)

3 comments

0

Umm, i dont want to destroy it, but i want to make less than 1 tool like in piggy

1

What do you mean by less than one tool? Do you want the player to have no tools?

0

Hold up, I think he wants pseudotools

This discussion is preserved as it was. New answers, comments, and votes are closed.