So I already know how to find a character, but I want to make a script that will delete any tool that character is holding and replace it with a new one. All I really need is the command that finds all tools in a model... I know it's simple, but I'm new. If you can help, thanks!
You can just use the UnequipTools function in the character's Humanoid to put away any tools the player is holding.
If you actually need to forcefully destroy any tools in the character, you can use a for loop to loop through every item in the character and then use an if statement along with the IsA function to check if each object is a Tool, and then destroys it.
--I will be using a variable called char to reference the character to show you that the character is needed here. Replace char with the path to the character to make it work as intended. local charChildren = char:GetChildren() --Gets the children of the character. for n = 1, #charChildren do --Repeats the code wrapped in the for loop by the amount of children in the character. if charChildren[n]:IsA("Tool") then --Check if the nth child of the character is a tool. charChildren[n]:Destroy() --Destroys the nth child that is a tool. end end
To shorten the code above, you can use something called a generic for loop to reference the child directly.
--I will be using a variable called char to reference the character to show you that the character is needed here. Replace char with the path to the character to make it work as intended. for i,v in pairs(char:GetChildren()) do --i is the position of the value in the table, v is the value, or the child that we're currently looking at. if v:IsA("Tool") then --Checks if v is a tool. v:Destroy() --Destroys v, the tool. end end --See how we write less compared to the last piece of code.
I hope this answered your question. If it did, be sure to accept my answer.
Happy scripting!