generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: FindPartsInRegion3 Help

Previous Thread :: Next Thread 
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
08 Feb 2015 03:13 PM
Purpose: this script is designed to spread grass along a grid. Basically turn anything green. So I'm using FindPartsInRegion3 to create a spread like effect.

Problem: the script spreads like a grid as it should, but soon after it gains some odd shape. At the first part and last part the spread should have a rectangular appearance.

Photos:

Beginning of the script it appears to be working: http://www.roblox.com/Before-item?id=214130108
After a little it gains some odd shape: http://www.roblox.com/After-item?id=214130259

Script:

Point = script.Parent

a1 = 5
a2 = 5
a3 = 5

for i = 1,100 do
wait(0.5)
a1 = a1+5
a2 = a2+5
a3 = a3+5
local Point1 = Vector3.new(Point.Position.x-a1,Point.Position.y-a2,Point.Position.x-a3)
local Point2 = Vector3.new(Point.Position.x+a1,Point.Position.y+a2,Point.Position.x+a3)
local Region = Region3.new(Point1,Point2)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,500)) do
if Part:findFirstChild("Grass") then
if Part.Grass.Value == false then
Part.BrickColor = BrickColor.Green()
Part.Grass.Value = true
else
print("NA")
end
else
print("No value to change")
end
end
end

Is my method of spreading not the correct way in order for a grid effect for the spread?
Report Abuse
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
08 Feb 2015 03:47 PM
bump
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
08 Feb 2015 03:57 PM
findPartsInRegion3 only takes up to 20 parts.
Report Abuse
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
08 Feb 2015 04:30 PM
It appears to be taking a lot more then that. What do you suppose is an alternative way then?
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
08 Feb 2015 04:36 PM
Inefficient, but you could make a table (or model) of 'grasses' then loop around a point and turn them green using raycasting.
Report Abuse
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
08 Feb 2015 04:51 PM
So would that also work if I had buildings or other parts standing on the grass? Would they also turn to grass around the same time the parts below them do?
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
08 Feb 2015 04:54 PM
Assuming by your code, the grasses seem to have a value identifying themselves as such. So you could still use that value before turning them grass.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
08 Feb 2015 05:01 PM
That's because your Region3 isn't correctly formatted. It is losing its uniformly rectangular shape.

Region3's must be formatted Region3.new(MIN, MAX) where MIN and MAX are Vector3s with the smallest (MIN) values and highest (MAX) values.

Here's a function I use:

function FormatRegion3(v3,_v3)
return Region3.new(
Vector3.new(
math.min(v3.x, _v3.x),
math.min(v3.y,_v3.y),
math.min(v3.z,_v3.z)
),
Vector3.new(
math.max(v3.x, _v3.x),
math.max(v3.y,_v3.y),
math.max(v3.z,_v3.z)
)
)
end;

Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
08 Feb 2015 05:06 PM
I guess, but still doesn't change the fact that it takes up only up to 20 parts
Report Abuse
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
13 Feb 2015 04:09 PM
I'm still confused on how exactly to incorporate that into my script.

I tried changing it to:

for _,Part in pairs(game.Workspace:FindPartsInRegion3(FormatRegion3(Point1,Point2),nil,500)) do

or even

for _,Part in pairs(game.Workspace:FindPartsInRegion3(FormatRegion3(1,100),nil,500)) do

But keep getting the error:

Workspace.Script:4: attempt to index local 'v3' (a number value)
Report Abuse
tyler5819 is not online. tyler5819
Joined: 14 Feb 2010
Total Posts: 683
13 Feb 2015 07:47 PM
Bump? :D
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image