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: Surface Detection

Previous Thread :: Next Thread 
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
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 is not online. 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
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
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 is not online. 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
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