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

Why does the else work, but the if doesn't?

Asked by 4 years ago

Hi, I'm very new to this, and I'm having a hard time understanding why my code isn't working.

score = 500

if score > 100 then
    Script.Parent.BrickColor = BrickColor.new("Really red")

else    
    script.Parent.BrickColor = BrickColor.new("Really blue")
end

If the variable 'score' is less than 100 the brick changes to the color 'Really blue' as expected. It's only when I make 'score' above 100, (like in the above example), where the brick color remains unchanged? Why is this?

1 answer

Log in to vote
1
Answered by 4 years ago

You capitalized the "script" in line 4, it should look like this

score = 500

if score > 100 then
    script.Parent.BrickColor = BrickColor.new("Really red")

else    
    script.Parent.BrickColor = BrickColor.new("Really blue")
end
0
Thank you, and sorry for wasting your time with a stupid mistake! XxMishMashxX 19 — 4y
0
Everybody makes mistakes, it's part of the learning process! jediplocoon 877 — 4y
0
Do I mark this post as answered and give reputation by doing so? How do I do that? XxMishMashxX 19 — 4y
0
If a post correctly answered your question, then go to the bottom of the answer and find the button "accept answer", and click on that jediplocoon 877 — 4y
View all comments (2 more)
0
I can't find the accept answer button :/ XxMishMashxX 19 — 4y
0
It's all good, I have plenty reputation so I don't really need any more of it jediplocoon 877 — 4y
Ad

Answer this question