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

Does anybody know what's wrong with my 'if' Statement?

Asked by 10 years ago

Well I understand a bit of Lua but I need help on this if statement.

function 
Game.Workspace.Part1 = P1
Game.Workspace.Part2 = P2

if P1 and P2 = new.Color("Bright red") then      --Here is my problem, how do you say color like this?
    Print("They are both red!")
end

Anyone know?

4 answers

Log in to vote
3
Answered by 10 years ago

Well number 1, you're using = instead of ==, number 2, the if statement is incorrect syntax, and number 3, new.Color isn't valid syntax. This is how it should be written:

local P1 = game.Workspace.Part1
local P2 = game.Workspace.Part2
if P1.BrickColor.Name == "Bright red" and P2.BrickColor.Name == "Bright red" then
    print("They are both red!")
end

Hope this helped!

*Note: if you still have trouble with using BrickColor, click here: BrickColor

0
DUDE THANKYOU, THAT WORKED! InsideExotic 5 — 10y
0
If you would know, how would I play music in it? If you know can you edit this? InsideExotic 5 — 10y
Ad
Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
P1 = Game.Workspace.Part1 
P2 = Game.Workspace.Part2 

if P1 == P1.BrickColor("Bright red") and P2 == P2.BrickColor("Bright red") then      --Here is my problem, how do you say color like this?
    Print("They are both red!")
end

This should fix it. But I don't exactly know if it will because of the 'colors'

Lol, I forgot that it can't be =, it has to be == :/

0
It says: 'then' expected near '=' I'll try to understand that. InsideExotic 5 — 10y
Log in to vote
0
Answered by 10 years ago

I don't know if it is supposed to be written like this, just try it out:

if P1 and P2 = BrickColor.new("Bright red") then
0
Ok thanks I'll get back to you in a sec. InsideExotic 5 — 10y
0
Ok then. If it doesn't work, at least I tried. bloonblaster2000 55 — 10y
Log in to vote
0
Answered by 10 years ago

Hmm I have tryed all of them, It seems hard to do if statements with parts propertys.

Answer this question