I have a function which makes plates dissapear, but once the Model is empty it will give an error, as there are no more plates left, and break the whole script, here's what I have:
1 | local Grass = game.Workspace.Classic.Grass:GetChildren() |
2 | if #Grass = = 0 then |
3 | -- I'm not sure how to "stop" the rest of the function |
4 | else |
5 | -- Plates code |
If you want to exit the code, simply use 'return'. You can learn more about return here: http://wiki.roblox.com/index.php?title=Function#Using_Return
This is the code you should use.
1 | local Grass = game.Workspace.Classic.Grass:GetChildren() |
2 | if #Grass = = 0 then |
3 | return -- Exits this if #Grass is 0 |
4 | else |
5 | -- Plates code |
6 | end |
There's another way you could do this to remove a few lines by just checking if grass is not 0.
1 | local Grass = game.Workspace.Classic.Grass:GetChildren() |
2 | if #Grass ~ = 0 then -- If #Grass isn't equal 0 then continue |
3 | -- Plates code |
4 | end |