|
| 27 May 2014 07:30 PM |
How do I detect if a certain surface is touched by a part, such as the top surface? Basically, if a character steps on the top of the block, something will happen.
function onTouch(part) -- Probably right here. if (part.Parent == nil) then return end if (part.Parent:findFirstChild("Humanoid") == nil) then return end --blah script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 May 2014 07:32 PM |
Compare the position of the part to the position of whatever hit it.
local topSide = part.CFrame * CFrame.new(0, part.Size.Y/2, 0); local bottomSide = part.CFrame * CFrame.new(0, -part.Size.Y/2, 0); local leftSide = part.CFrame * CFrame.new(-part.Size.X/2, 0, 0); local rightSide = part.CFrame * CFrame.new(part.Size.X/2, 0, 0); local backSide = part.CFrame * CFrame.new(0, 0, part.Size.Z/2); local frontSide = part.CFrame * CFrame.new(0, 0, -part.Size.Z/2); |
|
|
| Report Abuse |
|
|
|
| 27 May 2014 07:36 PM |
So...
local topSide = part.CFrame * CFrame.new(0, part.Size.Y/2, 0);
function onTouch(part) if (part.Parent == nil) then return end if (part.Parent:findFirstChild("Humanoid") == nil) then return end --blah script.Parent.topSide.Touched:connect(onTouch) -- Is this right? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 May 2014 07:39 PM |
| No. Those are just the CF's of the sides of the part, compare it and the thing that hit it's length and see which it is most closest too, basically. |
|
|
| Report Abuse |
|
|