Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can I have help with this Part Changer?

Asked by
awfulszn 394 Moderation Voter
9 years ago
local ChangePart = game.Workspace.Part

if ChangePart.BrickColor == BrickColor.Red() then
    ChangePart.BrickColor = BrickColor.Yellow()
or
    ChangePart.BrickColor == BrickColor.Green()
end

I need help with this please, I want it so if it is red, it will change to yellow, or if it is not red it will change to green, please help. xD

0
I see that error and another one on line 5. Or should be else. Spongocardo 1991 — 9y

3 answers

Log in to vote
3
Answered by 9 years ago

You've got two errors in your script. The first one is that you are using or in the wrong place. In an if statement, you need else if you want to do something if the condition of the if statement isn't true.

Secondly, you only need one equals sign on line 6. One equals sign = is for assigning values and two equals signs == is for comparing values, such as your condition in line 3.

Your script should look like this when you fix both of these errors:

local ChangePart = game.Workspace.Part

if ChangePart.BrickColor == BrickColor.Red() then
    ChangePart.BrickColor = BrickColor.Yellow()
else --Else is used if the condition above is not met.
    ChangePart.BrickColor = BrickColor.Green() --One = sign for assigning values, two = signs for comparing values.
end

I hope this helped you. If my answer helped, be sure to accept it. :)

Link for conditional statements.

Link for the list of operators you can use.

0
Thank you! This has helped me in my game! awfulszn 394 — 9y
0
You're welcome. Be sure to accept my answer, it's the tick button to the left. Spongocardo 1991 — 9y
Ad
Log in to vote
6
Answered by 9 years ago

You have two errors.

The first being that you need to replace or with else. Else is for if statements.

The second being that you used two equals signs (==) on line 6 when you should have only used one.

Here's the fixed script.

local ChangePart = game.Workspace.Part

if ChangePart.BrickColor == BrickColor.Red() then
    ChangePart.BrickColor = BrickColor.Yellow()
else
    ChangePart.BrickColor = BrickColor.Green()
end

Hope this helped.

If there's more than one part in workspace, I suggest renaming that part.

0
Yep! That helped! Thank you for the answer! awfulszn 394 — 9y
Log in to vote
-1
Answered by 9 years ago
wait 5

add something like that

0
Thanks! awfulszn 394 — 9y

Answer this question