So, when ever there is a rank door, and someone that is allowed opens it, then that allows others able to come in since the door is opened.
01 | local rank = 4 |
02 | local groupID = 6609636 |
03 | script.Parent.Touched:connect( function (hit) |
04 | if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then |
05 | if (game.Players [ hit.Parent.Name ] :IsInGroup(groupID) and game.Players [ hit.Parent.Name ] :GetRankInGroup(groupID) > = rank) then |
06 | script.Parent.CanCollide = false |
07 | script.Parent.Transparency = . 9 |
08 | wait( 1 ) |
09 | script.Parent.CanCollide = true |
10 | script.Parent.Transparency = 0 |
11 | else |
12 | script.Parent.CanCollide = true |
13 | end |
14 | end |
15 | end ) |
I also put the Local Script in the door seeing if that would work, but it didn't.
The reason the code doesn't work is because local scripts don't run in workspace. I suggest to make a local script in StarterPlayerScripts and use that code.
01 | local door = workspace:FindFirstChild( "Door" , true ) --Change this to the name of the door |
02 | local rank = 4 |
03 | local groupID = 6609636 |
04 | door.Touched:connect( function (hit) |
05 | if hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then |
06 | if game.Players [ hit.Parent.Name ] :IsInGroup(groupID) and game.Players [ hit.Parent.Name ] :GetRankInGroup(groupID) > = rank then |
07 | door.CanCollide = false |
08 | door.Transparency = . 9 |
09 | wait( 1 ) |
10 | door.CanCollide = true |
11 | door.Transparency = 0 |
12 | else |
13 | door.CanCollide = true |
14 | end |
15 | end |
16 | end ) |