Help for a newbie in scripting

Hello!

I just sketched a script… It was necessary for certain parts to gradually change their color to the one specified in the script. But, as you understand, if this act got away with me and brought the desired result, then I would not bother you with a request to help me…

In short, this script doesn’t work, and would like to know how to make it work.

Finally, let me introduce you to the culprit of this venture:

function changeColor() game.Workspace.RainbowParent.Rainbow1.BrickColor and game.Workspace.RainbowParent.Rainbow12.BrickColor = BrickColor.Red()
wait(8) game.Workspace.RainbowParent.Rainbow2.BrickColor and game.Workspace.RainbowParent.Rainbow11.BrickColor = BrickColor.Blue()
wait(10) game.Workspace.RainbowParent.Rainbow3.BrickColor and game.Workspace.RainbowParent.Rainbow10.BrickColor = BrickColor.Yellow()
wait(12) game.Workspace.RainbowParent.Rainbow4.BrickColor and game.Workspace.RainbowParent.Rainbow9.BrickColor = BrickColor.Blue()
wait(14) game.Workspace.RainbowParent.Rainbow5.BrickColor and game.Workspace.RainbowParent.Rainbow8.BrickColor = BrickColor.new(“Pinc”)
wait(16) game.Workspace.RainbowParent.Rainbow6.BrickColor and game.Workspace.RainbowParent.Rainbow7.BrickColor = BrickColor.new(“Toothpaste”)
wait(18)
end
changeColor()

And it is not valid… HELP!

Click the view tab and then click “Output”. When running the script, do you see a red message? That will tell you where the script is breaking.

1 Like

You can’t change a part’s color by doing BrickColor.Red. Instead do the top like you did at the bottom, with BrickColor.new(“Red”). Also, make sure you’re spelling correctly. I see “Pinc”, make sure you change that to “Pink”. For future reference, you can also do .Color = Color3.fromRGB(0,0,0) ← (Enter in the color code you want here)

2 Likes

I know what the error of this script is, but I don’t know how to fix it. And by asking for help here, I was hoping you would help correct it so to speak.

1 Like

I am saying can you show or tell me the error? I might know if you tell me.

1 Like

Why don’t you just make a variable for rainbow parent. You’re copying tons of code, repeating the same stuff. You can do:

local rainbow = game.Workspace.RainbowParent

Then you just do:

rainbow.Rainbow1.BrickColor = Color3.fromRGB()

1 Like

You’re not using ‘and’ properly in your script. Instead of writing:

game.Workspace.RainbowParent.Rainbow1.BrickColor and game.Workspace.RainbowParent.Rainbow12.BrickColor

You have to write it out, like this:

game.Workspace.RainbowParent.Rainbow1.BrickColor = BrickColor.new("Really red")
game.Workspace.RainbowParent.Rainbow12.BrickColor = BrickColor.new("Really red")

And instead of writing BrickColor.Red(), use BrickColor.new(“Really red”). Here’s a list of all the colors on roblox.

2 Likes

Excellent. I will take note of your instructions and follow your advice, and it will take me some time to achieve this goal, and then… a positive outcome is not difficult to guess.

Unfortunately, you cannot use the “and” operator that way. You must set the color of each part separately. Something like this:

function changeColor() 
	game.Workspace.RainbowParent.Rainbow1.BrickColor = BrickColor.Red()
	game.Workspace.RainbowParent.Rainbow12.BrickColor = BrickColor.Red()
	wait(8) 
	game.Workspace.RainbowParent.Rainbow2.BrickColor = BrickColor.Blue() 
	game.Workspace.RainbowParent.Rainbow11.BrickColor = BrickColor.Blue()
	wait(10) 
	game.Workspace.RainbowParent.Rainbow3.BrickColor = BrickColor.Yellow() 
	game.Workspace.RainbowParent.Rainbow10.BrickColor = BrickColor.Yellow()
	wait(12) 
	game.Workspace.RainbowParent.Rainbow4.BrickColor = BrickColor.Blue() 
	game.Workspace.RainbowParent.Rainbow9.BrickColor = BrickColor.Blue()
	wait(14) 
	game.Workspace.RainbowParent.Rainbow5.BrickColor = BrickColor.new("Pink") 
	game.Workspace.RainbowParent.Rainbow8.BrickColor = BrickColor.new("Pink")
	wait(16) 
	game.Workspace.RainbowParent.Rainbow6.BrickColor = BrickColor.new("Toothpaste") 
	game.Workspace.RainbowParent.Rainbow7.BrickColor = BrickColor.new("Toothpaste")
	wait(18)
end

changeColor()
2 Likes