i want to Anchor all parts/MeshParts or an R15 player but when i try this
local plaan = char:GetChildren()
for i=1, #plaan do
if plaan[i].ClassName=="MeshPart" or "Part" then
plaan[i].Anchored=true
end
end
it still tries to Anchor Humanoid
i want to Anchor all parts/MeshParts or an R15 player but when i try this
local plaan = char:GetChildren()
for i=1, #plaan do
if plaan[i].ClassName=="MeshPart" or "Part" then
plaan[i].Anchored=true
end
end
it still tries to Anchor Humanoid
For this, I particularly recommend using pairs to iterate through a table and :IsA() to find parts and anchor them in the rig.
local plaan = char:GetChildren()
--Since we are not using the index, we can set it to _.
--v here is the objects in the table.
for _,v in pairs(plaan) do
--"BasePart" automatically detects Parts and MeshParts.
if v:IsA("BasePart") then
v.Anchored = true
end
end
Thanks it works now
You did not explain why the OP's code failed.
Unlike in everyday, where common sense acts as a filler for some shortfalls, no such thing exists in programming. With that said, the problem here is line 3 for you,
if plaan[i].ClassName=="MeshPart" or "Part" then
it is generally implied in everyday english that the meaning of it is:
if plaan[i].ClassName=="MeshPart" or plaan[i].ClassName=="Part" then
but, no implications like that occur with the complier, which is exceptionally picky,instead of that is checks if plaan[i].ClassName == "MeshPart" is a truthy value(not false or nil) and checks if "Part" is a truthy value, instead of checking if plaan[i].ClassName is part.
Hopefully this helped solve your problem
i would also like to point out that you can check if plaan[i]:IsA("BasePart"), which i think encompasses both meshparts and normal parts
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
only anchor HumanoidRootPart