Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GetGroupsAsync in group rank door. Help please! ?

2 answers

local groupid = <groupid> —Change to the groupid

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr:IsInGroup(groupid) then
              local grouprank = plr:GetRankInGroup(groupid)
              —This will check if the player is in the group and get their group id
              if grouprank >= 1 then
                  print("Player is rank: "..grouprank)
              end
              script.Parent.CanCollide = false
              script.Parent.Transparency = 0.5
              wait(0.5)
              script.Parent.CanCollide = true
              script.Parent.Transparency = 0
        end
    end
end)

Just put this inside the part/door you want to be hidden and open when a player that is in the group touches

1 comment

0

Don't spoon feed

For you to use "GetGroupsAsync", I've made a module for all ROBLOX users that want an easy way to do this! https://www.roblox.com/library/1693869984/ROBLOX-Player-Group-Module-REDONE

Here's how it would work in your code, which would be under the door:

local group = 0 --Change to the groupID
local rank = 0 --Change to the min rankID
local GM = require(01693864088)
local killDoor = false --Kill when the player touches and it not the correct rank.

script.Parent.Touched:connect(function(part)
	if part.Parent and part.Parent:FindFirstChild('Humanoid') then
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr then
			if GM:GetRankInGroup(plr, group) >= rank then
				script.Parent.CanCollide = false
				wait(1)
				script.Parent.CanCollide = true
			elseif killDoor then
				part.Parent.Humanoid.Health = 0
			end
		end
	end
end)

Just change the group and rank value.

1 comment

0

Ew deprecated code and spoon feeding

This discussion is preserved as it was. New answers, comments, and votes are closed.