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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 31 Jul 2014 07:27 PM |
| b3 helllpp pplleeeaassseeee |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 31 Jul 2014 07:28 PM |
| Yea, but theres nothing ontop .-. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 31 Jul 2014 07:57 PM |
| also it moves the part regardless |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2014 08:09 PM |
wat What're you trying to do?
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|