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

Is this the right way to script this?

Asked by
Prioxis 673 Moderation Voter
11 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
1if game.Workspace.Part1.BrickColor = BrickColor.new("White") then
2game.Workspace.Part1.BrickColor = BrickColor.new("Black")
3end

I'm a alright scripter but the if, then, else, elseif have always confused me when it comes to coding

1 answer

Log in to vote
4
Answered by 11 years ago

When you're comparing stuff, like if game.Workspace.Part.Anchored = true that would be incorrect. You have to use == to see if something is true. Also things like else and elseifcan be very useful in an if function. For example;

1if game.Workspace.Part.Anchored == true then
2    print 'part is anchored'
3else
4    print 'part is not anchored'
5end

So you see what else is used for? Basically if that isn't true. elseif is used like this:

1if game.Workspace.Part.Anchored == true then
2    print 'part is anchored'
3elseif game.Workspace.Part2.Anchored == true then
4    print 'part2 is anchored'
5end

So basically you can use to if's in one function! Pretty useful right?

I hope you understand if functions and comparing objects! Also if this helped please accept the answer and a little credit would be nice :)

0
Thank you! :D Prioxis 673 — 11y
Ad

Answer this question