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

How do i check and unequip a tool in a local script?

so this is inside a button that clears your inventory.

script.Parent.Visible = false
local p = game.Players.LocalPlayer
local items = p.Backpack:FindFirstChildOfClass("Tool")
local activated = false

script.Parent.MouseButton1Click:connect(function()
	local tool = game.Players.LocalPlayer.Backpack:GetChildren()

	script.Parent.Parent.Popcatsword.Visible = true
	script.Parent.Parent.TextButton.Visible = true
	script.Parent.Parent.shrek.Visible = true
	script.Parent.Parent.bow.Visible = true 
	for i, child in ipairs(tool) do
		child:Activate()
		child:Deactivate()
		child:Destroy()
	end
	script.Parent.Visible = false
end)

1 answer

I was a little confused by your post title, but if you're looking for a button that clears your inventory then this would do it:

script.Parent.MouseButton1Click:connect(function()
    for _, tool in ipairs(game.Players.LocalPlayer.Backpack) do
        if Tool:IsA("Tool") then
            Tool:Destroy()
        end
    end
end)

You can add any of the visibility settings you had as needed.

I'm not entirely sure what you were trying to accomplish with activating and deactivating the tool. If that was your intent, let me know and I can try to help.

1 comment

0

Ok, so sorry about that, basically this is a local script in a button that is supposed to remove all items in your inventory. I wanted to have one that gives you weapons and then when you want to switch a weapon it deletes it from your inventory. It worked fine when a tool wasn't equipped, but when it was it didn't delete the tool. I want to check if it is equipped then unequip it so it can delete

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