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

I'm a beginner. Anyone knows the flaw with this 'code' block?

Asked by
net_h 13
4 years ago
paper = game.Workspace.trihard
paper.Transparency = 1
if
paper.Transparency == 1 then
 paper.BrickColor = BrickColor.new("Really red")
if
paper.BrickColor == "Really red" then
print("it is transparent + red")
else 
    print("it isnt")
end
end

this prints "it isnt" what is the flaw here? i'm trying to make it transparent and red and if it is then it prints "it is transparent + red"

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago

"Really red" is a string. When checking brick color, you want to compare brickcolors.

this statement is TRUE if your brick's color is the Really red brick color:

your part's brickcolor == BrickColor.new("Really red")

but this statement is NOT since your brickcolor is not a string.

your part's brickcolor == ("Really red")

paper = game.Workspace.trihard
paper.Transparency = 1

if paper.Transparency == 1 then
    paper.BrickColor = BrickColor.new("Really red")

    if paper.BrickColor == BrickColor.new("Really red") then
        print("it is transparent + red")
    else 
        print("the brick's transparency is 1, but it's brick color is NOT red.")
    end
end

0
God bless you. Although I did not see what you meant at the beginning I found the error now. Thanks. net_h 13 — 4y
Ad

Answer this question