"Attempted To Index Nil With Material"

You can write your topic however you want, but you need to answer these questions:

Error I have no idea how to fix,

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes, But nothing worked.
while true do
	task.wait(0.1)
	if heatval.Value > 500 then
		for i = 1,169,1 do
			atmo.BrickColor = BrickColor.new("Buttermilk")
			workspace.Parts:GetChildren()[i].Material = Enum.Material.Neon
			wait(0.6)
			if heatval:GetPropertyChangedSignal("Value") then
				if heatval.Value < 500 then
					while true do
						task.wait(0.1)
						if heatval.Value < 500 then
							for i = 1,169,1 do
									workspace.Parts:WaitForChild()[i].Material = Enum.Material.Plastic
									wait(0.6)
								end
							end
						end
					end
				end
			end
		end
	end

(THIS IS A SMALL PART OF MY SCRIPT!!)
The error is coming from here:

						if heatval.Value < 500 then
							for i = 1,169,1 do
									workspace.Parts:WaitForChild()[i].Material = Enum.Material.Plastic
									wait(0.6)
``` Can Anyone Help?

If I am sure, you should use :GetChildren() instead of WaitForChild

I edited that after seeing something else, the error was from :GetChildren()

Does it error immediately when you join the game or is the folder just empty?

Would It Help if I sent a video?

image

Hmm, Seems like I fixed it by just making the Folder a Variable EX: Workspace.Parts is now partsfolder which is local partsfolder = Workspace:WaitForChild(“Parts”)

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