on line 2, is there a better way to get the parent's move stat? i dont want to have to type a function for each number (4,5,6,7,8, etc.)
also is there a way to project selection boxes from line 4 according to the move stat ?
like a move stat of 3 would be 3 bricks in each direction, 4 would be 4 in each direction, etc.
(if it's math, i suck at math)
for i, v in pairs(game.Workspace.Map:GetChildren()) do if script.Parent.Move.Value == 3 then if v.Name == "TerrainB" then Instance.new("SelectionBox", v) if script.Parent.Move.Value == 4 then if v.Name == "TerrainB" then Instance.new("SelectionBox", v) if script.Parent.Move.Value == 5 then if v.Name == "TerrainB" then Instance.new("SelectionBox", v) end end end end end end end
This may be a small improvement for superalp1111 answer:-
You might be able to use if we do not need to check the value ranges each time:-
if script.Parent.Move.Value > = 3 and script.Parent.Move.Value <= 10 then for i, v in pairs(game.Workspace.Map:GetChildren()) do if v.Name == "TerrainB" then Instance.new("SelectionBox", v) end end end
Method 2, this would be faster as only one check is made instead of two possible checks when putting the "if script.Parent.Move.Value > = 3 and script.Parent.Move.Value <= 10 then " 1st:-
for i, v in pairs(game.Workspace.Map:GetChildren()) do if v.Name == "TerrainB" then if script.Parent.Move.Value > = 3 and script.Parent.Move.Value <= 10 then Instance.new("SelectionBox", v) end end end
Hope this helps.
If you are going to type absolutely same thing in every if condition, this may help you.
for i, v in pairs(game.Workspace.Map:GetChildren()) do if script.Parent.Move.Value > = 3 and script.Parent.Move.Value <= 10 then if v.Name == "TerrainB" then Instance.new("SelectionBox", v) end end
So you can type as much conditions as you want if you put "and" and "or" between conditions. For ex. This script will work when value is between 3 and 10, or when equal to 3 or 10.