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

Why is my script for converting parts to terrain not working?

I am executing this in a place and I have no idea why it isn't working.

local t = game.Workspace.Terrain

for i, P in ipairs(game.Workspace:GetChildren()) do
	if P.Transparency = 0 and P.Material = Enum.Material.Ice then
		t:FillBlock(P.CFrame, P.Size, Enum.Material.Snow)
		wait()
		P:Destroy()
		wait(1)
	end
end

I get an error message saying that material is not a valid member of camera.

1 answer

✓ Accepted answer

You need to add in a check to make sure what you are filling in is a BasePart, so:

local t = game.Workspace.Terrain

for i, P in ipairs(game.Workspace:GetChildren()) do
	if P:IsA("BasePart") and P.Transparency = 0 and P.Material = Enum.Material.Ice then -- changes made here
		t:FillBlock(P.CFrame, P.Size, Enum.Material.Snow)
		wait()
		P:Destroy()
		wait(1)
	end
end

Hope I helped!

~TDP

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