Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
2

How do I make a group only door?

Asked by 6 years ago

How do I make a group only door? I know how to link a game to a group but I don't know how to make doors where only certain ranks can go inside.

Example: A founder room. Only the founder can enter.

3 answers

Log in to vote
0
Answered by 6 years ago

You would do so like this:

local door = script.Parent -- Change me to where the door is
local groupId = 0 -- The digits at the end of the URL for your group

door.Touched:connect(function(hit) -- When the door is touched
    if (hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and game.Players:FindFirstChild(hit.Parent.Name)) then
        if (game.Players[hit.Parent.Name]:IsInGroup(groupId)) then
            door.CanCollide = false
            wait(1)
            door.CanCollide = true
        else
            hit.Parent.Humanoid.Health = 0 -- Kill them if they're not in the group
        end
    end
end)
Ad
Log in to vote
0
Answered by
Kozero 120
6 years ago

I wanted to make it an anonymous function to make the code slightly shorter.Make sure the script is in the door.

GroupID = 12345 --Change this to your groups ID
Door = script.Parent
Kill = true --if you want them to die if there in the group set it to true otherwise to false

Deb = false
script.Parent.Touched:connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
player = game.Players:GetPlayerFromCharacter(p.Parent)
if player then
if not Deb then
Deb = true
if player:IsInGroup(GroupID) then
Door.Transparency = 0.5
Door.CanCollide = false
wait(0.2)
Door.Transparency = 0
Door.CanCollide = true
Deb = false
end
elseif not player:IsInGroup(GroupID) then
if Kill then
p.Parent.Humanoid.Health = 0
Deb = false
end
end
end
end
end)
0
00:55:11.894 - Error in script: unexpected symbol near '01' Alyssall 0 — 6y
Log in to vote
-2
Answered by 6 years ago
                                        -- Group Rank Based Door Script V1.4 --
                                              -- By: DeathPossession --
                    ------------
                    --SETTINGS--
                    ------------
--Current Group--
GroupIdenabled = true--Enable or Disable the group and rank check feature, as well as Exceptions settings below. Set "true" to enable and "false" to disable. 
GroupId = 1080850 --Change this to GroupID of your group.
min = 10
max = 255 --Change this to the maximum Group Rank Value (Rank 0-255) a Player can enter.
Exceptions = {"Yournamehere"} --[[Put names of Players that are exempted from the rank, group, and/or ItemID system. 
    This can be used to allow non-group members or anyone you want, clearance through the door. Put their names 
    in this format:{"Playername","Playername2"} NOTE: To disable remove the names from this list.--]]

--Item ID--
ItemIdenabled = false --Enable or Disable the Item ID feature. Set "true" to enable and "false" to disable. 
ItemId = 0 --The item/badge they can own in their inventory to allow passage through the door. Change it to the ItemID of the specific item/badge.

--Specific Settings--
local KilluponTouched = false --If "true", kills non group members/incorrectly ranked members, if "false" does not let them in.
local WaitTime = 0.5 --Amount of time door remains open before closing.
DoorTransparency = 0.9 --Change this value to the Transparency you want the door to return to. (ex. 0=For Solid)
Door = script.Parent --Do not modify or remove.
Q = false --Do not modify or remove.
                                             ----------
                                             --Script--
                                             ----------
--Checks the Player Against Names in "Exceptions" List--
function CheckExceptions(name) 
for i = 1,#Exceptions do 
--Converts Strings to all Upper Case--
if (string.upper(name) == string.upper(Exceptions[i])) then return true end 
end return false end

--Makes Sure Player is Within Guidelines (Correct rank, group, possible exceptions, and/or they have the correct item within their inventory)--
--Group Check--
if GroupIdenabled == true then
function Touched(Part)
local Human = Part.Parent:findFirstChild("Humanoid")
if Q then return end
Q = true 
if Part.Parent then
p=game.Players:getPlayerFromCharacter(Part.Parent)
if p then 
if p:GetRankInGroup(GroupId) >= min and p:GetRankInGroup(GroupId) <= max or (CheckExceptions(Human.Parent.Name))then
AccessGranted() 
else
print("Nice Try, Skrub")
if KilluponTouched then Part.Parent:breakJoints()
wait(WaitTime)
end end end end  Q = false end end

--Item Check--
if ItemIdenabled == true then
function Touched(Part)
local human = Part.Parent:findFirstChild("Humanoid")
if Q then return end
Q = true 
if Part.Parent then
p=game.Players:getPlayerFromCharacter(Part.Parent)
if p then 
if game:getService"BadgeService":UserHasBadge(p.userId,ItemId)then
AccessGranted()
else
print("Own the Item to Gain Access")
if KilluponTouched then Part.Parent:breakJoints()
wait(WaitTime)
end end end end  Q = false end end

--Opens Door If Player's Rank was Correct--
function AccessGranted()
print("Access Granted")
Door.Transparency = 0.9
Door.CanCollide = false
wait(WaitTime)
Door.CanCollide = true
Door.Transparency = DoorTransparency
end






Door.Touched:connect(Touched)

Answer this question