Only paints that are specifically labeled as being compatible with Styrofoam should be used with the material. Failure to do so can damage the Styrofoam and cause craters and holes in a craft project.
Spray paint is particularly risky because of the chemicals found in it that cause Styrofoam to melt, but there are exceptions. Reading the label is the best policy. Even if a paint is compatible with Styrofoam, one should keep in mind that multiple layers of paint will be needed to evenly coat the nooks and crannies in the material.
Alternatively, another product can be used to coat the Styrofoam first so that otherwise unsafe paints can be applied. Plaster of Paris, Mod Podge and Foam Finish work well, although one should take care to sand away any rough patches afterward and apply multiple layers if needed.