|
| 24 Nov 2013 10:15 PM |
with the Touched event?
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2013 10:21 PM |
Example: -- script.Parent.TopSurface.Touched:connect(function(hit) print(hit.Name) end) -- If a part hits the top of script.Parent it prints the part's name.
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Nov 2013 06:24 PM |
| What do you mean by surface, as in the top surface of a part? If so, I don't think you can do that unless you make a thin invisible brick on top of a part, and check when they touch the invisible brick. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 06:24 PM |
^ Or use simplish math.
TopSurface would be position + (size.y/2) or something like that |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2013 06:28 PM |
| Well that wouldn't really work with a Touch. You can't touch a position but you can use a loop to check your position but that may cause lag. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 25 Nov 2013 06:41 PM |
Support this thread please: http://www.roblox.com/Forum/ShowPost.aspx?PostID=118708187
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 06:42 PM |
No, how would that work with walk-through parts? Exactly |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2013 06:44 PM |
@cnt Whatever surface was touched first.
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 06:45 PM |
| How would that work if you get teleported into the object |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2013 06:47 PM |
A new surface perhaps? InsideSurface
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 06:48 PM |
| lol or just use pretty basic math |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
| |
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 25 Nov 2013 06:54 PM |
getLeast = function(tab) startnum = math.huge ind = 0 if type(tab) == "table" then for i, v in pairs(tab) do if type(v) == "number" and v < startnum then startnum = v ind = i end end end return startnum ~= math.huge and startnum, ind or startnum == math.huge and "error" end -- getSurfaceHit = function(obj, hitter) SurfaceTable = {"FrontSurface", "BackSurface", "RightSurface", "LeftSurface", "TopSurface", "BottomSurface"} local lengthx = obj.Size.X/2 local lengthy = obj.Size.Y/2 local lengthz = obj.Size.Z/2 local front = (obj.CFrame*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*lengthz)) local back = (obj.CFrame*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*-lengthz)) local right = (obj.CFrame*CFrame.Angles(0, math.rad(-90), 0))*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*lengthx) local left = (obj.CFrame*CFrame.Angles(0, math.rad(90), 0))*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*lengthx) local top = (obj.CFrame*CFrame.Angles(math.rad(90), 0, 0))*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*lengthy) local bottom = (obj.CFrame*CFrame.Angles(math.rad(-90), 0, 0))*(obj.CFrame:toObjectSpace(obj.CFrame).lookVector*lengthy) -- local num, index = getLeast({(hitter.Position-front).magnitude, (hitter.Position-back).magnitude, (hitter.Position-right).magnitude, (hitter.Position-left).magnitude, (hitter.Position-top).magnitude, (hitter.Position-bottom).magnitude}) print(num, index, SurfaceTable[index]) return SurfaceTable[index] end
-- Example Usage: for i, v in pairs(script.Parent:GetChildren()) do if v:IsA("BasePart") then v.Touched:connect(function(hit) surface = getSurfaceHit(v, hit) print(surface) v[surface] = "Studs" end) end end
-- Not mine |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 06:55 PM |
| That is way to inefficient... |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 25 Nov 2013 06:58 PM |
Don't tell me, I didn't make it. You're the best scripter here. I saw it posted a long while ago and remembered it. http://www.roblox.com/Forum/ShowPost.aspx?PostID=96530849 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 07:00 PM |
| I'm not the best but there have been better ways then chaos's |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 07:03 PM |
| There is a lot, I'm just the most active on this sub-forum I would assume |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 25 Nov 2013 07:07 PM |
You mean... you're the most active best scripter in scripting helpers? Well sure. You make me feel small :/ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 07:08 PM |
No, I said I'm probably the most active compared to a lot of the people. I didn't mean the active best... |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 25 Nov 2013 07:09 PM |
Then I jump back to my question Then who is ;o |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Nov 2013 07:10 PM |
| There is no best, there is always someone better than myself and yourself. And I don't know who the best is... |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2013 07:11 PM |
Best = Sorcus 'Nuff said.
~ℇℸℇℛηαℒℱίℛℇℇαℸℇℛ~ |
|
|
| Report Abuse |
|
|