Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
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?

0
is the neck another Motor6D or a basepart? starmaq 1290 — 5y
0
just check if the thing's name is equal to "Neck" or whatever with using an "and" starmaq 1290 — 5y
0
if list[i].ClassName == "Motor6D" and list[i].Name == "Neck" then starmaq 1290 — 5y
0
no, i wanna clear all motor6ds and leave the neck (dont remove neck) SunxLightz 30 — 5y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

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
0
why people using ~= not ==? SunxLightz 30 — 5y
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. XviperIink 428 — 5y
0
^ or comparison. NickAtNick 163 — 5y
Ad

Answer this question