I wanted to make a wall that'd let only a certain rank go through.
This is what i've tried but idk how to define a group role:
01 | script.Parent.Touched:Connect( function () |
02 |
03 | if game.Players.LocalPlayer.Name = = "UsernameHere" then |
04 |
05 | script.Parent.CanCollide = false |
06 |
07 | else |
08 |
09 | script.Parent.CanCollide = true |
10 | end |
11 |
12 | end ) |
Group ranks are ranged from 1-255
, so what you need to do is check if the player's rank is bigger than or equal to the rank you want and then run the code.
You can do that through a function
called GetRankInGroup
which is a function of a player object.
Example:
01 | script.Parent.Touched:Connect( function (hit) |
02 | if hit.Parent:FindFirstChild( "Humanoid" ) then -- check if what touched is a character |
03 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
04 | if player:GetRankInGroup(groupIdHere) > = 20 then -- replace 20 with rank number you want |
05 | script.Parent.CanCollide = false |
06 | else |
07 | script.Parent.CanCollide = true |
08 | end |
09 | end |
10 | end ) |
Hope I helped, if you have any questions please let me know
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | -- just see if player is high enough rank |
3 | if player:GetRoleInGroup(group ID goes here) = = ( "Name of rank" ) then |
4 | script.Parent.CanCollide = false |
5 | else |
6 | script.Parent.CanCollide = true |
7 | end |
8 | end ) |