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

UnequipTools is not a valid member of Tool?

Hi, I'm trying to make it so my script first unequips any tools they have open, then destroys them. I'd really like to make this work as having them NOT unequip first causes glitches with some animations and effects and what not for my games.

						for _,v in pairs(p.Backpack:GetChildren()) do
							if v:IsA'Tool' or v:IsA'HopperBin' then
								v:UnequipTools()
								v:Destroy()
							end 

1 answer

✓ Accepted answer

the UnequipTools() function is used with the player's humanoid so lets do this

First let's use that function on the humanoid

local p = player --change this

p.Character.Humanoid:UnequipTools()

Now let's remove all the player's tools in their backpack

local p = player --change this

p.Character.Humanoid:UnequipTools()

for _,v in pairs(p.Backpack:GetChildren()) do
	if v:IsA("Tool") then
		v:Destroy()
	end
end

We check that what we are destroying is a tool

Extra comments example:

local p = player --change this

for _,v in pairs(p.Character:GetChildren()) do
	if v:IsA("Tool") then
		v.Parent=p.Backpack
	end
end
for _,v in pairs(p.Backpack:GetChildren()) do
	if v:IsA("Tool") then
		v:Destroy()
	end
end

21 comments

0

Is there supposed to be more to this? Seems like it's cut off. What is local p = player supposed to be? ?__?

0

@LuckyAura I said 'change this' right after it, change it to the player who u want this to happen to, also no thats all

0

Alright, what would it be if I want it to happen to anyone?

0

I don't know in which way you will be implementing the script I gave you. You'd want to do this on the server side though if FE is on

0

@LuckyAura

0

Oh, FE isn't on

0

Then the script will work in both a localscript and regular script. But I recommend learning about FE

0

Everything you do should be fe compatible

0

I know that but what would player be changed to if I want it to be for anyone

0

I don't know what you are using this for thats the problem, a random person chosen? everyone at the same time?

0

it's part of a cloned GUI, so for the person that has their own copy of it open.

0

then assuming FE is off we can change it to local p = game.Players.LocalPlayer if its in a localscript

0

Not sure if it's cause in Studio, but instead of Unequipping and removing it, it just keeps it equipped and doesn't remove it.

0

If I deselect said tool myself, then when the script runs again, it just keeps the tool tool I had equipped but removes the others.

0

where is the script located

0

it is located inside of a Frame, that is in a ScreenGUI, inside of the StarterGUI. It's not removing unequipping the selected tool or even removing all of the other tools that were in the Backpack. :-(

0

if the UnequipTools function isn't working then you can replace it by going through all of the children of the character and if it's a tool move it to the backpack

0

Wouldn't it be close to this? for _,v in pairs(p.Backpack:GetChildren()) do Since the tools are moved from the backpack to the players model inside of Workspace, how would it look there as well?

0

I edited answer^

0

Thank you so much for your help man, I noticed that the reason it wasn't removing some things is because a few tools that I have are HopperBins, and I wasn't including it to remove those as well. Doh'!

0

;p accept answer :3

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