How do you create a seamless rank door?

The way I use it is by deleting the doors upon player entering the server. If the player is a staff member, delete the doors (on their client only). This is a better way of doing it, so you don’t have to worry about other people gaining access when a player opens it, for example, if the door opened for 2 seconds when a staff member walked into it.

5 Likes

So I know how to destroy the door on join using Destroy but how do you do it client sided? This has been a question on my mind for a while.

1 Like

Using a LocalScript. A LocalScript is on each client, but that doesn’t mean everyone gets access through the door. You can do your checks in the LocalScript, but just make sure that it’s in a place where client scripts can function (e.g. StarterPlayerScripts would be ideal for this)

1 Like

Ideally for this you’d want to use remote events, on server you would detect when someone has touched the trigger part and then proceed to check if the player meets the requirements of that door, then have the server fire the event to the client in order to open the door for them.

As for the reason behind your script causing lag, you have not included a debounce, meaning that every part that touches the trigger part will run the code.

1 Like

Would this work? Or did I just complicate it…

local plr = game.Players.LocalPlayer
 
if plr:GetRankInGroup (5206514) >=2 then
    if game.Workspace:FindFirstChild("SnackDoor") then
        game.Workspace.CurrentCamera.SnackDoor:Destroy()
    end
else
    local door = game.Workspace:FindFirstChild("SnackDoor"):Clone()
    door.Parent = game.Workspace.CurrentCamera
    door.CanCollide = true
    door.Anchored = true
    door.CFrame = game.Workspace:FindFirstChild("SnackDoor")
end

Seem to be over complicating it just a little bit.

If the door is already there, make sure that it is by default:

  • Anchored
  • CanCollide set to true
local plr = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(function()
	if plr:GetRankInGroup (5206514) >=2 then
  		if game.Workspace:FindFirstChild("SnackDoor") then
   	    		game.Workspace.SnackDoor:Destroy()
    		end
	end
end)

Should work just as well.

2 Likes

Oh oops lol thanks! Sometimes I just think I need to do extra.

It doesn’t seem to work. I don’t know if I am doing something wrong, I will send some screenshots…
image

Nvm it works just not on studio

Well not detailed, script but I think, problem is in parent.
Try this script:

 GroupIdenabled = true--Enable or Disable the group and rank check feature. Set "true"

to enable and “false” to disable.

GroupId = 5206514 --Change this to GroupID of your group.
min = 2
max = 255 --Change this to the maximum Group Rank Value (Rank 0-255) a Player can enter.

--Item ID--
ItemIdenabled = false --Enable or Disable
ItemId = 0

local KilluponTouched = true
local WaitTime = 0.5
DoorTransparency = 1
Door = script.Parent 
Q = false 
										
 
--Makes Sure Player is Within Guidelines (Correct rank, group, possible, 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 = 1
Door.CanCollide = false
wait(WaitTime)
Door.CanCollide = true
Door.Transparency = DoorTransparency
end






Door.Touched:connect(Touched)

This should work in studio as well:

local plr = game:GetService("Players").LocalPlayer
if plr:GetRankInGroup(5206514) >= 2 then
	if game:GetService("Workspace"):FindFirstChild("SnackDoor") then
		game:GetService("Workspace").SnackDoor:Destroy()
	end
end
1 Like

How many of these are you using? I personally use this system (Extremely similar code) for a military base I’m helping develop. We currently have five of these doors and have so far had no problems in terms of lag. Albeit, the base is still a WIP, and only has around 1.5k parts currently.

Also, have you tried putting the script in a LocalScript? That way, even if dozens of players are entering and leaving, the lag would be drastically reduced, as multiple people hitting the same door can cause the server to run the script over and over.

1 Like

Sad to see no love for Collision Filtering. This would definitely make for a seamless door. I currently use this for my group where there’s three groups per tier of a group rank (visitor, staff, high rank) and areas of the map collide with some groups and others don’t.

4 Likes

Ok so I made the script, it worked and then I went to sleep. Then I got up and tested it again and it is just working very oddly… Like when I first got on I could not go through, so I invited some people to test it and at the sart they could not go through, but eventually could. Then I got the owner to come on and test it and he could go through just fine.

I have a issue where the script just stopped working one day

1 Like

Same thing, it just works very oddly. I think you can replace “FindFirstChild” with “WaitForChild” and it might work better.

Does this give access in the group with the rank 2 and above to get in?

Yes, as it compares if the player’s rank is greater than or equal to 2.

It currently isn’t working for me…

Here, fully made script:

Insert a local script, inside Starter pack > Starter player scripts:

local player = game.Players.LocalPlayer

if player:GetRankInGroup(1234) >= 321
for _,door in pairs(workspace[“location of the folder, or part easier to create a folder then insert the part throguh there.”]:GetChildren()) do
door.CanCollide = false
end
end

2 Likes