Attempting to make a passive script that removes the players weapon if selected, so far this is what i have which doesnt work. A local script that clones in the player when activated.
function getTool() for _, kid in ipairs(script.Parent:GetChildren()) do if kid.className == "Tool" then kid.Parent = game.Players.LocalPlayer.Backpack end end end getTool()
:IsA(ClassName) basically does the same thing but supports base classes, so use that instead. So, to answer your question:
function getTool() for _, kid in ipairs(script.Parent:GetChildren()) do if kid:IsA("Tool") then kid.Parent = game.Players.LocalPlayer.Backpack end end end getTool()
Another method is to call :UnequipTools() on the character's humanoid. Assuming the script's parent is the character, you could simply use the following.
script.Parent.Humanoid:UnequipTools()