I am trying to make a platform that checks if multiple players are touching at the same time. What is the simplest way to do that? This is pretty much all I have l:
1 | platform.Touched:connect( function (hit) |
2 | local player = hit.Parent |
3 | if player.Character:FindFirstChild( "RobberMatchTag" ) then |
4 | local robber = player |
5 |
6 | end |
7 | end ) |
All you would need to do, is something like this:
01 | Touching = { } |
02 |
03 | platform.Touched:connect( function (hit) |
04 | local Valid = true |
05 | local player = hit.Parent |
06 | if player.Character:FindFirstChild( "RobberMatchTag" ) then |
07 | local robber = player |
08 | for i = 1 , #Touching do |
09 | if Touching [ i ] = = robber then --Checks if players already touching |
10 | Valid = false |
11 | end |
12 | end |
13 | if Valid = = true then |
14 | Touching [ #Touching+ 1 ] = robber |
15 | end |
I think this should work. If you have any problems please leave a comment below. Hope I helped :P