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 » Scripting Helpers
Home Search
 

Re: :FindPartsInRegion3

Previous Thread :: Next Thread 
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 06:53 PM
Im having issues with this script:

mSize2 = bed3:GetModelSize()
Point1 = bed3.Center.Position
Point2 = mSize2+Vector3.new(1,1,1)
Region = Region3.new(Point1,Point2)
for i,v in pairs(game.Workspace:FindPartsInRegion3(Region,nil,8)) do
print(v.Parent.Name)
end

its only supossed to print the names of the beds withtin one stud of the bed,but if I move the bed 2-5 studs away from another bed, it still prints the name until I move it like 20 studs away. I think the Region is set wrong, this is my first time using this. Help?
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 06:56 PM
bmp
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:13 PM
b1
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:17 PM
b2
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:27 PM
b3 helllpp pplleeeaassseeee
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
31 Jul 2014 07:28 PM
Region3 is a 3D area you know right?
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:28 PM
Yea, but theres nothing ontop .-.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 07:31 PM
You're starting the Region3 at the center of the bed and extending outwards towards one side.
Do some basic math to offset from the center.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 07:34 PM
Plus, You're setting point2 based on the size.
Point1 = bed3.Center.Position - (mSize2 / 2 + Vector3.new(1,1,1))
Point2 = bed3.Center.Position + (mSize2 / 2 + Vector3.new(1,1,1))
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 07:35 PM
*Cough*

Point1 = bed3.Center.Position - mSize2 / 2 - Vector3.new(1,1,1)
Point2 = bed3.Center.Position + mSize2 / 2 + Vector3.new(1,1,1)
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:36 PM
I tried dividing the size by 2, since the center is in the middle of the object. still didnt work?
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:37 PM
nvm it works. Thanks!
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:41 PM
I have another error, I tried using an if statement and it doesnt work:

mSize2 = bed3:GetModelSize()
Point1 = bed3.Center.Position - mSize2 / 2 - Vector3.new(1,1,1)
Point2 = bed3.Center.Position + mSize2 / 2 + Vector3.new(1,1,1)
Region = Region3.new(Point1,Point2)
if game.Workspace:FindPartsInRegion3(Region,nil,8) then
bed3.PrimaryPart = bed3.Center
cf = bed3:GetPrimaryPartCFrame()
bed3:SetPrimaryPartCFrame(cf*CFrame.new(0,-.5,0))
end

no error, its supossed to move the bed down if theres another bed next to it.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 07:43 PM
...
FindPartsInRegion3 returns a table with all the objects contained in said region.
Use the ignore list to put your current bed in, iterate through the returned table, and check if either of them belong to another bed model.
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:54 PM
I tried this:

mSize2 = bed3:GetModelSize()
Point1 = bed3.Center.Position - mSize2 / 2 - Vector3.new(1,1,1)
Point2 = bed3.Center.Position + mSize2 / 2 + Vector3.new(1,1,1)
Region = Region3.new(Point1,Point2)
for i,v in pairs (game.Workspace:FindPartsInRegion3(Region,nil,8)) do
bed3.PrimaryPart = bed3.Center
cf = bed3:GetPrimaryPartCFrame()
bed3:SetPrimaryPartCFrame(cf*CFrame.new(0,-.5,0))
end

but it moves too low.
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:57 PM
also it moves the part regardless
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 08:09 PM
wat
What're you trying to do?
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 08:10 PM
Move the bed slightly lower if someone tried to place it next to another bed. Heres the whole function:

ouse.Button1Down:connect( function()
bed3 = bed:clone()
bed3.Parent = player.Character.Humanoid
objbed = player.Character.Humanoid:findFirstChild("ObjBed")
main = bed3.Center
bed3.PrimaryPart = main
pos = objbed.Center.Position
pos2 = Vector3.new(0,0,0)
objbed:MoveTo(pos2)
bed3:MoveTo(pos)
-- bed3:SetPrimaryPartCFrame(bed3.PrimaryPart.CFrame * CFrame.Angles(math.rad(angle)))
bed3.Name = "Prev"..num
num = num+1
print(num)
for i,v in pairs(bed3:getChildren()) do
if v:IsA("Part") then
v.Transparency = 0
v.CanCollide = true
end
end
mSize2 = bed3:GetModelSize()
Point1 = bed3.Center.Position - mSize2 / 2 - Vector3.new(1,1,1)
Point2 = bed3.Center.Position + mSize2 / 2 + Vector3.new(1,1,1)
Region = Region3.new(Point1,Point2)
for i,v in pairs (game.Workspace:FindPartsInRegion3(Region,nil,8)) do
bed3.PrimaryPart = bed3.Center
cf = bed3:GetPrimaryPartCFrame()
bed3:SetPrimaryPartCFrame(cf*CFrame.new(0,-.5,0))
end
end)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 08:14 PM
...
FindPartsInRegion3 will determine if there are any parts within said area.
Put the bed you are basing it on into the ignore list
Use the for loop to check if there are any beds near
then lower the bed with another loop
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 08:16 PM
I have no idea how to do that, I just started using FindPartsInRegion3 like 5 min ago.
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 08:16 PM
and the said area is 1 stud more than the size of a model.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 08:21 PM
Yes.
I gave you the points to do that.
FindPartsInRegion3 will return the parts within it(Max of 100)
So basically something like this:
{Workspace.Bed2.Part1,Workspace.Bed2.Part2}

for i,v in pairs(FindPartsInRegion3) will loop through every object found
Be sure to put the current bed into the ignore list

for i,v in pairs(game.Workspace:FindPartsInRegion3(Region,IGNORELISTHERE,100)) do
if v.Parent == "NAME OF BED HERE" then
print("Found Another bed")
end
end
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 08:23 PM
How would I put things into the ignore list...? Look at my place called "Bed test" to see what Im saying is wrong btw.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
31 Jul 2014 08:24 PM
It's an ignoredescendants list
Just put the bed model into it. .-.
Seeing as you defined it as 'bed3' you literally just put that in there.
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 08:28 PM
oh. so, How would I use it without a for i,v loop so it will run:

bed3.PrimaryPart = bed3.Center
cf = bed3:GetPrimaryPartCFrame()
bed3:SetPrimaryPartCFrame(cf*CFrame.new(0,-.5,0))

only once

brb
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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