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

Why does it say attempt to index nil with Get Descendants?

The Tower has descendants inside of it but I think it's telling me that it does not have any descendants


for i, object in ipairs(towerToSpawn:GetDescendants()) do
	if object:IsA("BasePart") then
		PhysicsService:SetPartCollisionGroup(object, "Tower")
		
	end
end

``

1 answer

the tower probably has not loaded yet which is why it is set to nil try to use Instance:WaitForChild() in the line where you set the variable

local towerToSpawn = game:GetService("Workspace"):WaitForChild("Tower")

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