I have a function that basically turns ore into metal or raw meat into cooked meat. Both if Statements work independently, but with the first one in the function, when It is run on something that is "raw meat" (aka not an ore) the if statement recognizes that ore is nil and the script breaks. What I want it to do is recognize the ore is nil and then go on to the next If statement. Should be an easy fix I just must be missing something. Thanks guys! (I originally had just two separate if statements and no elseif, but then i tried the else if and neither work.
01 | function heatUp(part) |
02 | local heat = part.Heat |
03 | local newName = heat.NewName.Value |
04 | local newColor = heat.NewColor.Value |
05 | local newRef = heat.NewRef.Value |
06 | local newTrans = heat.NewTrans.Value |
07 | local newOther = heat.NewOther:GetChildren() [ 1 ] |
08 |
09 | part.Name = newName |
10 | part.BrickColor = newColor |
11 | part.Reflectance = newRef |
12 | part.Transparency = newTrans |
13 |
14 | if part.Ore.Value ~ = nil then |
15 | part.Mesh:remove() |
Your problem is that you wrote
1 | else if |
Instead of
1 | elseif |
The problem lays in your if statement. You use else if
instead of elseif
, wich would mean it requires an end for every new if.
What you're basicly doing is:
01 | function stuff(args) |
02 |
03 | if Statement then |
04 | -- stuff |
05 | else |
06 | if OtherStatement then |
07 | -- stuff |
08 | end |
09 | end |
10 |
11 | --see the problem here? Not enough ends. |
The easy way to solve this:
You gotta change your else if
into elseif
, because it'd require a few extra ends otherwise. That's all.
Example:
1 | function stuff(args) |
2 |
3 | if Statement then |
4 | -- stuff |
5 | elseif OtherStatement then |
6 | -- stuff |
7 | end |
8 | end |