well, it depends, if you want to know when a specific part is in range, than this should work;
01 | local function in_Range(part 1 ,part 2 ,range) |
02 | if (part 1. Position - part 2. Position).magnitude < = range then |
16 | if in_Range(game.Workspace.gate,game.Workspace.car, 30 ) = = true then |
17 | if debounce = = false then debounce = true |
18 | game.Workspace.gate.CanCollide = false |
20 | game.Workspace.gate.CanCollide = true |
or, if you want to see if any part in a model is in range, then replace the last part with this;
03 | if debounce = = false then debounce = true |
05 | local carModel = game.Workspace.carModel:GetChildren() |
07 | for i = 1 , #carModel do |
08 | if in_Range(game.Workspace.gate,carModel [ i ] , 30 ) = = false then |
14 | if debounce = = true then |
15 | game.Workspace.gate.CanCollide = false |
17 | game.Workspace.gate.CanCollide = true |
or if you want to know when any part at all is in range, I hate you.