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

How do i make a door for a rank in the group?

1 answer

✓ Accepted answer

I will talk you through 2 ways of doing it.

Method 1 This script will assume that what you are allowing them to walk-through is one part, and that the script is a child of the part. This script will allow non-ranking members through if a correct ranking member has walked through 5 seconds before.

SERVER SCRIPT

local GroupId = 000000
local RankId = 000

script.Parent.Touched:Connect(function(hit)
	if hit.Name == "HumanoidRootPart" then
		pcall(function()
			if game.Players:FindFirstChild(hit.Parent.Name) then
				if game.Players:FindFirstChild(hit.Parent.Name):GetRankInGroup(GroupId) >= RankId then
					script.Parent.CanCollide = false
					--script.Parent.Transparency = 1
					wait(5)
					script.Parent.CanCollide = true
					--script.Parent.Transparency = 0
				end
			else
				return
			end
		end
	end
end)

Method 2 These next scripts assume that the door is a single part again, although this time will not allow non-ranking members through at all. WARNING: This script will make the door invisible to correct ranking members. Both of the scripts below are needed for this way of doing it.

Create a RemoteFunction in ReplicatedStorage and call it GetRank.

LOCAL SCRIPT PLACED IN REPLICATEDFIRST

local DoorName = "" --// Make sure that the door part is in the workspace and not in a model.

if game.ReplicatedStorage.GetRank:InvokeServer() == true then
	if workspace:FindFirstChild(DoorName) then
		workspace:FindFirstChild(DoorName):Destroy()
	else
		error("Could not find a door by the name of "..DoorName.." in the Workspace!")
	end
end

SERVER SCRIPT PLACED IN SERVERSCRIPTSERVICE

local GroupId = 000000
local RankId = 000

game.ReplicatedStorage.GetRank.OnServerInvoke = function(Player)
	if Player:GetRankInGroup(GroupId) >= RankId then
		return true
	else
		return false
	end
end

Message me if it isn't working!

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