Ok so I made a post similar to this that you can see here
But my issue is that it doesn’t work that well. So no matter what lower ranks can never get in so that is good. But either it takes like 15 minutes for it to recognize you have a rank higher than 2, lets you in right away, or it just doesn’t let you in at all. Here is the local script below that is located in StarterPlayerScripts
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)
Please respond with answering these three questions. What is causing this? How can I fix this? Is there a more efficient way to do this?
game:GetService("Players").PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(5206514) >= 2 then
if workspace.SnackDoor then
workspace.SnackDoor:Destroy()
end
end
end)
This is a bit more optimal, the global variable “workspace” is faster, GetService is faster than direct indexing Players.
Well, that would not work for three reasons. I want it client sided, I want it to be that a certain rank in a group can go through, and I am wanting it to be smooth and not lag.
You could tag every “snackdoor” using collectionservice:AddTag()
You could also use nocollisionconstraints to make it so the player who has the correct rank just doesn’t collide with the snackdoor, this is a serversided way to do it which is probably the best way that shouldn’t lag.
Try using CanCollide instead of using “Destroy()”
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.CanCollide = false
else
game.Workspace.SnackDoor.CanCollide = true
end
end
end)
“Don’t tested yet!”
I don’t understand why you’re checking when a child is added to the Players service. I would personally make a group door like this (in StarterPlayerScripts):
local p = game:GetService("Players").LocalPlayer
if p:GetRankInGroup(5206514) >= 2 then
game:GetService("Workspace"):WaitForChild("SnackDoor"):Destroy()
end
So we have Kohls Admin in that game and I think it is interfereing with the door. Because if we give someone admin they can go through, and if we take it away they can’t which is really weird, because once you destroy the door, it is gone right?
The door may have other scripts that allow that to happen. Look for anything that might be allowing Kohl’s to have a relationship with the door.
Also, since you want it on the client:
local plr = game:GetService("Players").LocalPlayer
if plr:GetRankInGroup(5206514) >= 2 then
if workspace.SnackDoor then
workspace.SnackDoor:Destroy()
end
end
Should work just fine, and of course, being on the client will delete solely for the client.