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:
script.Parent.Touched:Connect(function() if game.Players.LocalPlayer.Name == "UsernameHere" then script.Parent.CanCollide = false else script.Parent.CanCollide = true end 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:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then -- check if what touched is a character local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player:GetRankInGroup(groupIdHere) >= 20 then -- replace 20 with rank number you want script.Parent.CanCollide = false else script.Parent.CanCollide = true end end end)
Hope I helped, if you have any questions please let me know
game.Players.PlayerAdded:Connect(function(player) -- just see if player is high enough rank if player:GetRoleInGroup(group ID goes here) == ("Name of rank") then script.Parent.CanCollide = false else script.Parent.CanCollide = true end end)