Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a non-colliding part detect if a colliding part is inside it?

Asked by 8 years ago
Edited 8 years ago

I've tried GetTouchingParts, but that doesn't work since it only works with colliding parts. I've also tried Touched, but again, same problem. How do I tackle this problem? Edit: Sorry, I mean if the non-colliding part is inside it!

0
Con-Colliding parts can still use the touched event. User#11440 120 — 8y
0
Updated, sorry! coolyoshipower 42 — 8y

1 answer

Log in to vote
0
Answered by
Notwal 2
8 years ago

Math ;D I'm pretty happy with this.

01local part1size = workspace.part1.Size
02local part1position = workspace.part1.Position
03local part2size = workspace.part1.Size
04local part2position = workspace.part2.Position
05 
06function checkX()
07    local x1, x2 = part1size.X, part2size.X
08    local x = x1 + x2
09 
10    return(part1position.X + x > part2position.X or  part1position.X - x < part2position.X)
11end
12 
13function checkY()
14    local y1, y2 = part1size.Y, part2size.Y
15    local y = y1 + y2
View all 31 lines...
Ad

Answer this question