Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to correctly delete a tool from the backpack?

Asked by
nc2r 117
4 years ago

My question seems to be a duplicate, but isn't, as a separate question has arisen. I know that I can use Tool:Destroy() However, I only realised the issue as soon as I added a new tool. I have tool A, tool B, tool C, and tool D. If I delete tool 3, the issue is, then it will display as 1 tool A, 2 tool B, 4 Tool D. If I delete the third tool, then pressing 4 will still activate the fourth tool, pressing 3 will do nothing. So if I delete the tool, it goes 1, 2, 4. It seems deleting tools will not shift the hotbar numbers of subsequent tools accordingly. How can I fix this?

0
script? G2001H 75 — 4y
0
If you read the question, there is no need for a script nc2r 117 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Removing tools from the backpack will not shift them, no. As for how to do so, not sure on all the ins and outs of the player backpack but moving the tool out of the backpack then back into it will automatically shift it to the first available slot. There may be a cleaner way of doing this but I haven't really seen a way to just reassign the slot a tool belongs to outside of just creating your own backpack.

Ad
Log in to vote
0
Answered by
nc2r 117
4 years ago
Tool:Destroy()
local Items = Player.Backpack:GetChildren()
for i, Child in ipairs(Items) do
    Child.Parent = nil
    Child.Parent = Player.Backpack
end

Answer this question