Enum.Material.Slate is not a valid EnumItem

I cannot figure out why this error keeps coming up. Slate is for sure a valid EnumItem but it just doesn’t work for some reason. This is my code.

local function getWriteableMaterial(Material)
	return Enum.Material[Material]	
end
game.Workspace.Part.Material = getWriteableMaterial("Slate")

Thanks so much for the help.

Copy-pasting your code exactly as it is works fine for me without errors.

1 Like

This is working fine for me also what is the exact error you are getting?

1 Like

Just gonna say something, but you can just set the part’s Material using the string itself.

game.Workspace.Part.Material = "Slate"
1 Like

Is this the only code in your script? This code works perfectly.

This code doesn’t have a problem and I don’t think you tried debugging or testing it either, so I’m not quite sure why you’re posting a thread about it. To double over that, is there a reason you even need the function in the first place? You can set the Material of a part to an Enum’s string or the raw Enum.

game.Workspace.Part.Material = "Slate"
game.Workspace.Part.Material = Enum.Material.Slate
game.Workspace.Part.Material = Enum.Material[Material]