I have a script within a gui that allows the player to change the color of their hair/clothes/etc to whatever they choose. The problem is it can get pretty messy. I have a bunch of similar scripts for each color and it's really building up. Is there an easier way to call certain parts from a morph's head and chest parts?
playerman = script.Parent.Parent.Parent.Parent.Parent.Character function changecolor() -- headparts playerman.HeadPart.HairTop.BrickColor = BrickColor.new("Persimmon") playerman.HeadPart.Hair.BrickColor = BrickColor.new("Persimmon") playerman.HeadPart.EyebrowsMad.BrickColor = BrickColor.new("Really red") playerman.HeadPart.EyebrowsNeutral.BrickColor = BrickColor.new("Really red") playerman.HeadPart.HairBack.BrickColor = BrickColor.new("Persimmon") -- chest playerman.Chest.Cap.BrickColor = BrickColor.new("Salmon") playerman.Chest.Shirt.BrickColor = BrickColor.new("Crimson") playerman.Chest.Hat.BrickColor = BrickColor.new("Really red") wait() end script.Parent.MouseButton1Click:connect(changecolor)
I'm guessing you are putting that script inside each color button that they choose? I guess that since you are using script.Parent.MouseButton1Click
, i would recommend using a ModuleScript
and then just requiring it and calling it inside that script so you don't have to change every. single, script. it's a little more work but it's worth the effort.
This could help a little:
Make a variable that reffers to playerman.HeadPart
. Then make an array that contains all parts that are supposed to change their brickcolor to, for example "Really red". Repeat for every color. Then use a for loop to go through every part inside each array, and change its color.
http://wiki.roblox.com/index.php?title=Generic_for
You should look on addictedroblox1414's answer aswell. It's a pretty good idea. Do what he says, and just pass some arguments to the function that will tell it what colors it should switch to.
not that i know of, there might be a way but i cant find one.