gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:04 PM |
| ...if a player is above a part? ( Not touching, just above one) |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:07 PM |
for a,b in pairs(Game.Players:GetPlayers())do if b.Character and (b.Character.Torso.Position-script.Parent.Position).magnitude<5 then --Gotcha end end |
|
|
| Report Abuse |
|
|
spynaz
|
  |
| Joined: 17 Feb 2011 |
| Total Posts: 1326 |
|
|
| 07 Jan 2013 12:10 PM |
X = Part.Position.X Z = Part.Position.Z Y = Part.Position.Y Torso = Player.Torso
if Torso.Position.X == X and Torso.Position.Z == Z and Torso.Position.Y > Y then --script end
I hope that works. |
|
|
| Report Abuse |
|
|
spynaz
|
  |
| Joined: 17 Feb 2011 |
| Total Posts: 1326 |
|
|
| 07 Jan 2013 12:12 PM |
| @Robert, magnitude will activate if the player is within 5 studs of the brick, not above the brick. |
|
|
| Report Abuse |
|
|
spynaz
|
  |
| Joined: 17 Feb 2011 |
| Total Posts: 1326 |
|
|
| 07 Jan 2013 12:17 PM |
| Think of magnitude as an invisible bubble surrounding a part and when something enters that bubble, the script will activate. So it doesn't work in this case. |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:24 PM |
X = Part.Position.X Z = Part.Position.Z Y = Part.Position.Y Torso = Player.Torso
if Torso.Position.X == X and Torso.Position.Z == Z and Torso.Position.Y > Y then --script end
Will only work when the player is EXACTLY on his position. I ment like above the part, on any rotation with any size. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:29 PM |
for a,b in pairs(Game.Players:GetPlayers())do if b.Character and (b.Character.Torso.Position-script.Parent.Position).magnitude<5 and b.Character.Torso.Position.Y>script.Parent.Position then --Gotcha end end |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:30 PM |
| That will only check if the player is in the range, not location. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:30 PM |
Sorry, sleepy, lol.
for a,b in pairs(Game.Players:GetPlayers())do if b.Character and (b.Character.Torso.Position-script.Parent.Position).magnitude<5 and b.Character.Torso.Position.Y>script.Parent.Position.Y then --Gotcha end end |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:32 PM |
| As I said, before too, this will only check if it is in range. My house is not a circle :P |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:32 PM |
| I'm not sure what you are wanting, because that will check if the person is within 5 studs of the block, and they must be above it. |
|
|
| Report Abuse |
|
|
spynaz
|
  |
| Joined: 17 Feb 2011 |
| Total Posts: 1326 |
|
|
| 07 Jan 2013 12:34 PM |
X = Part.Position.X Z = Part.Position.Z Y = Part.Position.Y Torso = Player.Torso
if Torso.Position.X == X and Torso.Position.Z == Z and Torso.Position.Y > Y then --script end
That actually does check if it's above, see how it checks if the torso's y position is greater than the part's y position? |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:35 PM |
| Nope, how would I check the rotation of the part and see if the player is above the part, so it can place a Couch and not place a couch before your house, and not in the spawning area or something. |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:36 PM |
@theOtherDudeWhichNameIForgot That would check if it's literrally above the part, and I ment really any position above the part. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:40 PM |
xp,yp,zp=script.Parent.Position.X,script.Parent.Position.Y,script.Parent.Position.Z xs,ys,zs=script.Parent.Size.X,script.Parent.Size.Y,script.Parent.Size.Z yp=yp+ys/2 xp1,xp2,zp1,zp2=xp+xs,xp-xs,zp+zs,zp-zs for a,b in pairs(Game.Players:GetPlayers())do if b.Character then if b.Character.Y.Position > yp+4 if b.Character.Torso.Position.X < xp1 and b.Character.Torso.Position.X > xp2 then if b.Character.Torso.Position.Z < zp1 and b.Character.Torso.Position.Z > zp2 then --Gotcha end end end end end |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:42 PM |
| Thanks... but it wouldn't work with rotatable objects (my houses were just copy+paste. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:44 PM |
| That would check if a player is above that part, anywhere above it. |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:45 PM |
| But what if the part is 20 * 1 * 40? And it's rotated 90 degrees? That would make the whole thing kinda strange. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:46 PM |
if b.Character.Y.Position > yp+4
Will check if they are above the location where people would stand on the part, so if you want to also check even if they are touching the part, just change that line to
if b.Character.Y.Position > yp |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:46 PM |
| I see, so you mean the part that is check for people above it can rotate... |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:47 PM |
| If a part is rotated, it won't see the rotation. If a player is above the part without rotation, it'll work. |
|
|
| Report Abuse |
|
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:49 PM |
| It is rotated already :P And, you know, it's kinda hard to make all houses with the right CFrame and just other Sizes. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2013 12:49 PM |
| Correct. I see what you mean. Do you mind telling me what you need this script for? This sounds like some sort of mini game. |
|
|
| Report Abuse |
|
|
spynaz
|
  |
| Joined: 17 Feb 2011 |
| Total Posts: 1326 |
|
| |
|
gerit99
|
  |
| Joined: 21 Jul 2010 |
| Total Posts: 521 |
|
|
| 07 Jan 2013 12:51 PM |
| I have alot of houses, and these houses are kinda empty. So I need to check if the player is actually in his own house, so the player doesn't make a wall of couches. |
|
|
| Report Abuse |
|
|