I have used GetDescendants and GetChildren but I would only like to get certain parts of a model such as in a character. This is best I have got but it would only get the humanoid root part. I would appreciate help since I don’t want to create certain attachments for each body part.
for _, limbs in pairs(character:GetChildren()) do
if limbs.Name == ("HumanoidRootPart") or limbs.Name == ("Head") or limbs.Name == ("RightUpperArm") or limbs.Name == ("LeftUpperArm") or limbs.Name == ("LeftUpperLeg") or limbs.Name == ("RightUpperLeg") then
Attach = Instance.new("Attachment", limbs)
Attach2 = Instance.new("Attachment", limbs)
Attach.Visible = true
Attach2.Visible = true
Attach2.Position = Vector3.new(0, 0, 2.5)
end
end
local allowed = {
"HumanoidRootPart";
"Head";
"LeftUpperArm";
}
for _, Obj in pairs(Char:GetChildren()) do
if table.find(allowed, Obj.Name) ~= nil then
--do stuff on selected parts mentioned in table
end
end
It was working before but yours works as welll but when I try adding a part trail it would just put it one the root part? I am confused why it would do that with a part trail.
Well if the name of the trail matches the names mentioned in the table, it will get passed as true. Change the name of the trail to something unique compared to the parts mentioned in the table.
What do you mean match the names in the table and something unique how would that help?? Since I need to add it to all chosen body parts, and it is just a part effect parented to a folder in workspace.
But why descendants the folder is not going to be parented to the limbs
and also for some reason it would not delete the model it would just stop.
model = Instance.new("Folder")
model.Name = "Points"
model.Parent = workspace
local character = Tool.Parent
local humanoid = character:WaitForChild("Humanoid")
local rootpart = character:WaitForChild("HumanoidRootPart")
if humanoid and rootpart then
for _, limbs in pairs(character:GetChildren()) do
--if limbs:IsA("BasePart") then
if table.find(allowed, limbs.Name) ~= nil then
Attach = Instance.new("Attachment", limbs)
Attach2 = Instance.new("Attachment", limbs)
Attach.Visible = true
Attach2.Visible = true
Attach2.Position = Vector3.new(0, 0, 5)
Debris:AddItem(Attach, 9)
Debris:AddItem(Attach2, 9)
--[[while wait(0.1) do
local startPart = Attach.WorldPosition
local endPart = Attach2.WorldPosition
CreatePoints(startPart, endPart, 3, model)]]
end
end
while wait(0.1) do
local startPart = Attach.WorldPosition
local endPart = Attach2.WorldPosition
local segments = 3
--LightningDecor(startPart, endPart, segments ,model)
CreatePoints(startPart, endPart, 3, model)
end
Debris:AddItem(model, 9)
end