Destroy object's children

i want to know what to insert into a script to destroy all of a certain object’s children. i will use this as a weapon switching system.

add this to whatever you want to hide

function OnTriggerStay(trigger : Collider) {
     if(Input.GetKeyDown(KeyCode.E)) {
         var child = transform.GetChild(0);

hope this helps

I agree with @bobin115 that some sort of enabling or disabling might be better than Instantiate() and Destroy() for a weapons switching system. But here is an answer to the explicit question you ask:

for (var child : Transform in transform) {

Note that in general you want to avoid operations that modify the list you are iterating over using foreach, but Destroy() happens at the end of the frame, not when you make the call.