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: How to detect if a certain part touches a certain part?

Previous Thread :: Next Thread 
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
28 May 2013 01:31 AM
How can I detect if a certain part (With a special name) touches another part with a special name. For example if I had a part called "Wheel", and a part called "Spike", when Spike touches Wheel, it executes a script. How can I do this? Already had a failed attempt at the script using a key card script.

Report Abuse
gamert7 is not online. gamert7
Joined: 18 Nov 2008
Total Posts: 4986
28 May 2013 01:48 AM
-- Touched function with 'hit' in parentheses.
local part = hit.Parent:FindFirstChild("Spike")
if part~= nil then
-- stuff

end
end
-- connection line.
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
28 May 2013 01:54 AM
Put this in the wheel

script.Parent.Touched:connect(hit)
if hit.Name == "Spike" then
--execute whatever code u want
end
end)
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
28 May 2013 05:16 AM
gamert, I have this now, but it doesnt seem to work, I cant seem to figure out why,

function onTouched(hit)
local part = hit.Parent:FindFirstChild("Spike")
if part~= nil then
script.Parent:Remove()
end
end

connection = hit.Touched:connect(onTouched)



Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
28 May 2013 06:15 AM
boomp
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
28 May 2013 06:26 AM
script.Parent.Touched:connect(hit)
if hit.Name==whatever then
hit:Remove()

end
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
28 May 2013 06:28 AM
:connect(function(hit)




end)*
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
28 May 2013 11:28 AM
@Gamer's code won't work for you.


Try mine.




Need more help? Feel free to PM me :)
Report Abuse
gamert7 is not online. gamert7
Joined: 18 Nov 2008
Total Posts: 4986
28 May 2013 01:10 PM
Arkose is correct I should have used hit.Name
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
29 May 2013 06:30 AM
Okay Arkose.. when Spike hits the part, I get this error:

attempt to call a nil value
Report Abuse
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
29 May 2013 06:45 AM
@Im2 You got that from output right? That is because script. is a nil value unless you make it a variable in your command.

Try putting this extra line in the code: print("The Spike Destroyed the Wheel!")

So, when your Wheel hits the spike, it should print to output "The Spike Destroyed the Wheel!"
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
29 May 2013 04:11 PM
But! The spike does not pop the wheel in the script. Which is what it is supposed to do.
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
30 May 2013 02:20 AM
Bump
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
30 May 2013 04:40 PM
Bump
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
30 May 2013 08:26 PM
Once again, bump
Report Abuse
pheonixmaster is not online. pheonixmaster
Joined: 10 Jan 2009
Total Posts: 5361
30 May 2013 09:43 PM
This should go in the spike just for clarification. If it doesn't work then PM me.


function onTouched(hit)
if hit.Name == "Wheel" then -- You can change the name in the quotation marks
hit:remove() -- This deletes the wheel if it is hit with the spike
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
SockPuppetCow is not online. SockPuppetCow
Joined: 14 Sep 2012
Total Posts: 121
30 May 2013 09:52 PM
Straight, simple answer here: In Spike put this

script.Parent.Touched:connect(function(hit)
if hit.Parent.Name == "Wheel" then
--Whatever you want to do
end
end)
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
30 May 2013 10:38 PM
Thanks guys! Finally got it working!!
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