if game.Workspace.Part1.Transparency = 1 then game.Workspace.Part2.Color = DarkGreen end
I just started scripting in lua and just practicing some codes and this came up adn i do not know why this is wrong? (Trying to change the part2's color when part 1's transparency is at 1)
if game.Workspace.Part1.Transperence == 1 then -- the error is the u use only 1 =. == means is same as ~= means different as. and >= bigger and same. > only bigger as. <= smaller and same >only smaller as. game.Workspace.Part2.Color = BrickColor.DarkGreen() end
Your first problem: you're using = rather than == in the first line. When you check something, you use ==, and when you define a variable, you use =. Your second problem: you're setting the part's Color when you should be setting its BrickColor.
Fixed version:
if game.Workspace.Part1.Transparency == 1 then game.Workspace.Part2.BrickColor = BrickColor.new("Dark green") end
Also, a tip: use workspace
rather than game.Workspace
. Just makes things a bit easier.
You have to have two ==s because it signifies that the transparency is equal to 1. Also here's a re-written code if you want it
if game.Workspace.Part1.Transparency == 1 then game.Workspace.Part2.BrickColor = BrickColor.Green() end
Remember; you always need a double "equals" after an "if" or an "until" statement.
if game.workspace.part1.Transparency == 1 then game.workspace.part2.BrickColor = BrickColor.Green() end
The way I remember it is to do a peace sign. You lift up your middle finger and your index finger. These two fingers mean the two "equals" you need to add in there.
Your 'then' must be in the same line as 'if'. Here's your script:
if game.Workspace.Part1.Transparency = 1 then game.Workspace.Part2.Color = DarkGreen end