Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

Like when there's a door to a room that have tools that high ranks can use and how do u make it only for high ranks or only for a rank?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

Ad

Answer this question