Why do I have the error

hello

why do I have the error Players.napastnikiek1.PlayerGui.Manager.BulidMode.BulidLocal:17: attempt to index nil with ‘Name’

local script

for _, v in pairs(workspace.Map.Hall1:GetDescendants()) do
			if v.Name == "ExtraSlot" or v.Parent.Name == "MachineSlots" then
				v.Transparency = 1
				local clickDetector = v:FindFirstChildOfClass("ClickDetector")
				if clickDetector then
					clickDetector:Destroy()
				end
			end
		end

Can you add a print like this, so we can see what it’s erroring with

for _, v in pairs(workspace.Map.Hall1:GetDescendants()) do
print(v, v.Parent)
			if v.Name == "ExtraSlot" or v.Parent.Name == "MachineSlots" then

last logs

StartPart1 Hall1 - Client - BulidLocal:9
15:30:22.133 Conveyor StartPart1 - Client - BulidLocal:9
15:30:22.137 MachineSlots Conveyor - Client - BulidLocal:9
15:30:22.141 1 MachineSlots - Client - BulidLocal:9
15:30:22.145 ClickDetector nil - Client - BulidLocal:9

i see the parent of a clickdetector is nil, so it tries to get the name of nil, there’s your problem

you can probably fix it by checking if the parent is nil like this

if v.Name == "ExtraSlot" or v.Parent ~= nil and v.Parent.Name == "MachineSlots" then
1 Like

now everything works, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.