Answered by
6 years ago Edited 6 years ago
What you do in your code is a very common mistake new developers do when using "if" statements.
The thing with Lua (could apply to other languages as well) is that you need to provide what it should check.
Basically in your if statement here:
1 | if basePart.Parent.Name = = "BlueBarrel" or "RedBarrel" then |
you check if the basePart's parent name is "BlueBarrel" or if "RedBarrel" exists.
Since "RedBarrel" is not falsy (AKA. false, nil etc.), but exists, this will return true and the if statement will return true.
You probably thought that it would check if the basePart's parent name was "BlueBarrel" or "RedBarrel".
There is not much you have to change though:
1 | if basePart.Parent.Name = = "BlueBarrel" or basePart.Parent.Name = = "RedBarrel" then |