I want to limit the amount of tools that I can have equipped the regular is nine but I want mine to be two how can I achieve this???
Don’t do that, Limit the amount of tools you give to the player.
I want to make it it so only 2 can be equipped
You could just not give the player the tool unless they have less than 2 items in their backpack.
local player = nil -- choose what you want
for i, __ in pairs(player.Backpack:GetChildren()) do
if i <= 2 then
-- put the give tool script or whatever script here
end
end
The question is unclear, but I believe what you mean is how can you limit the amount of tools a player has in their inventory. You cannot equip nine tools, you can only equip one, so you probably mean the amount of tools a player has in their inventory. How you can do this is:
local Player -- Make sure you get the player.
for i, Tool in pairs(Player.Backpack:GetChildren()) do
if i > 2 then
game:GetService("Debris"):AddItem(Tool, 0) -- Delete the tool if they have more than two tools in their inventory.
end
end
Just run that loop everytime a player gets a new tool in their backpack or whenever you wanna check that.
I read over the script you dis fit would delete the tool. Instead of it of it being deleted can it just drop the currently equipment tool
If it can you can do that I hope
Here you go:
local Player -- Make sure you get the player.
for i, Tool in pairs(Player.Backpack:GetChildren()) do
if i > 2 then
Tool.Parent = workspace
end
end
If you want it to drop 1 tool instead of all, then:
local Player -- Make sure you get the player.
for i, Tool in pairs(Player.Backpack:GetChildren()) do
if i > 2 then
for thetool = 1, #Tool do
local ToolToDrop = Tool[math.random(#Tool)]
ToolToDrop.Parent = workspace
end
end
end
Thanks for the help
i likeed it