Group door script not working

Hello! I’m trying to make a group door for my hotel, but it isn’t working. I want it so all ranks with a rank ID of 4 or higher can go through this part, which is invisble.

local StaffDoor1 = game.Workspace.GroupDoor1
local StaffDoor2 = game.Workspace.GroupDoor2
local StaffDoor3 = game.Workspace.GroupDoor3

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(4880128) >=4 then
        StaffDoor1.CanCollide = false
        StaffDoor2.CanCollide = false
        StaffDoor3.CanCollide = false
    else
       
    end
end)

I tested in studio and in game but I couldn’t walk through.

1 Like

Well looking at your script. It seems like if one player joins with a ran higher or equals to 4 all of the players can come trough. Are you sure you have a Rank higher or equals to 4?

Edit: Seems like your Id goes to the group called Deluxe Hotels

1 Like

I am not sure, But I think it can work with a local script, try to create a local script like this:

local StaffDoor1 = game.Workspace.GroupDoor1
local StaffDoor2 = game.Workspace.GroupDoor2
local StaffDoor3 = game.Workspace.GroupDoor3
local Player = game.Players.LocalPlayer
if Player:GetRankInGroup(4880128) >=4 then
      StaffDoor1.CanCollide = false
      StaffDoor2.CanCollide = false
      StaffDoor3.CanCollide = false
else
       
end

I believe that way, Only players in the group will be able to pass the
Let me test it,I’ll edit this post

My rank’s ID is 18, and it is in a local script in Server script service.

LocalScript don’t run is ServerScript service. Try putting it in StartPlayerScripts

Edit: @LightningLion58’s script will work

Okay! I’ll try that now. 30 chars

Yes, that’s what I meant Luka.
My script works fine, I did not mention that it should be in the StarterPlayerScripts because I thought it is obvious. My script works for me. I used it with my group id and just created normal parts and named them.

Just tested in studio, it still doesn’t work.

Where did u put your script?
30 chars

Any output? It works just fine for me, is it a local script and in the StarterPlayerScripts?

I’ve been wanting to implement this in my game but I was hesitant because a few developers were telling me that exploiters are able to work around this and still get past. Can anyone confirm?

Yes, you would have to use collision groups for this.

It is in starter player scripts, there is no outputs and it is a local script.

Don’t put it in a local script, put it in a regular script under workspace

I don’t want it to let everyone in the server in though.

The best way is using Collision groups as @minecraftxrr said.

How exactly would I go about this?

minecraftxrrr No, it should be a local script for a reason, only players in the group should be able to go past it, and normal scripts can’t get LocalPlayer, if you put it in the workspace, everyone will be able to go past it, because it will be canCollide = false for everyone.
Don’t put it in a normal script.

If it is in starter player, there is no need for PlayerAdded because it’ll automatically run when the player joins

I’ve started looking into collision groups with this link: Collisions | Documentation - Roblox Creator Hub

Not sure if it is helpful.