Ok I have an issue I want to find the children's children of a folder so I can change their properites / load them in.
This is my script:
function onTouched(part) wait (0.5) if part.Parent:findFirstChild("Humanoid")~=nil then local map = script.Parent.Parent.Parent local waves = map.Waves print (waves) local Wave1 = waves.Wave1:GetChildren():GetChildren() print (Wave1) Wave1.Anchored = false Wave1.Transparency = 0 end end script.Parent.Touched:connect(onTouched)
So when someone touches this part it should make the things visible and make them not anchored.
Instead it just gives me this error:
Workspace.UpgradeOpen.Part.Script:7: attempt to call a nil value
it does print "Waves" from line 6 so it cant be the issue that it doesnt find the folder.
Any help will be appreciated!
you can't get children twice, i think you want to get the childrens after getting the childrens,,,,, well you can't get childrens on table (because get children returns table), so you should need to use ipairs loop i think
for _, instance in pairs(waves:FindFirstChild("Wave1"):GetChildren()) do -- get wave1 childrens for _, instancewave in pairs(instance:GetChildren()) do -- loop through instance childrensĀ (if there is no children, then it won't print anything print(instancewave.Name) -- you might need this one?? instancewave.Anchored = false -- or unanchor it, make lag lol end print(instance.Name) -- or this one instance.Anchored = false -- if it's already false then you can still make it false end
another way is to get descenants, get descenants are different than get children, because it get children, but if the children have childrens, then it gets the instance's children, until everything is clear
in coolfds solution i won't copy and paste because that do nothing
It might be because your object is nil or your defining the name as a nil object. Either you could do is if thats not the case. And 2 GetChildren() doesn't work. Use, GetDescendants() instead.
local wave1 = waves:FindFirstChild("Wave1"):GetDescendants()
Hopefully this helped.