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

How would I set up and call a function that can change multiple parameters of a part?

Let's say I want to change the material type to "neon", the color to "Really red", and the transparency to 0.8. And I'm going to make these same changes to different parts in several different functions of my script. Is there an efficient way to set up and call a single function that will make all of these changes to any part, so that I don't have to keep writing out the changes in full each time?

Apologies if this is simple to do - I'm new to scripting and I can't seem to figure it out.

1 answer

✓ Accepted answer
local part = script.Parent
function DoThingsToAPart(material, color, transparency)
	part.Material = material
	part.BrickColor = BrickColor.new(color)
	part.Transparency = transparency
end
DoThingsToAPart("Neon", "Really red", 0.8)

1 comment

0

Great, that works perfectly. Thank you!

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