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

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

Asked by 1 year ago

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

Log in to vote
0
Answered by 1 year ago

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")
Ad

Answer this question