So for example if you had part1 and part2, and you want something to happen when the two parts touch, is there a function for that? kind of like the onTouched function but i'm pretty sure that one only works when a humanoid touches the object. Thanks for any help guys!
COMMUNITY QUESTION
Is there a function that would start when two parts touch?
2 answers
OnTouched works for anything. It does not have to be a humanoid.
So:
part1.Touched:connect(function(hit)
if hit == part2 then
print("Part1 was touched by Part2")
end
end)
The touched event fires on anything that hits it. Keep in mind it's called Touched and not onTouched!
Part1 = workspace.Part1
Part2 = workspace.Part2
Part1.Touched:connect(function(Hit)
if Hit == Part2 then
print("Hit")
end
end)
1 comment
0
this is awesome! how can i make sure that this is constantly checked (like that the script keeps checking to make sure the parts are still touching)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
onTouched, but you would need to add "if" statements and such.