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

How do i clear player's children, but leave one of them?

function CleanChar()

local list = torso:GetChildren()

for i = 1,#list do

if list[i].ClassName == "Motor6D" then

list[i]:Destroy()

end

end

end

How do i remove everything but not the neck?

4 comments

0

is the neck another Motor6D or a basepart?

0

just check if the thing's name is equal to "Neck" or whatever with using an "and"

0

if list[i].ClassName == "Motor6D" and list[i].Name == "Neck" then

0

no, i wanna clear all motor6ds and leave the neck (dont remove neck)

1 answer

✓ Accepted answer

Just check if the name isn't neck

for i,v in pairs(torso:GetChildren()) do
    if v.ClassName == "Motor6D" and v.Name ~= "Neck" then
        v:Destroy()
    end
end

3 comments

0

why people using ~= not ==?

0

" == " means that if something equals something while " ~= " mean that if somethings does not equal something. I dont know how to explain it to you but some people may.

0

^ or comparison.

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