Access Only Door

I need help with a script that I bought. I want to make it so it is only accessible to a certain group rank. I want it so you click it, and it only works if you match the rank scripted in. Someone help me please! If you need more details on it, add me on Discord! jake1260#3323

This is the script:

gl = script.Parent.MovingOne.Glass
duration = TweenInfo.new(1)
ts = game:GetService(“TweenService”)
script.Parent.Kontrolboks.ClickDetector.MouseClick:Connect(function()

local goal = {}
goal.CFrame = script.Parent.Cel.CFrame

local goal2 = {}
goal2.CFrame = script.Parent.Cel2.CFrame

local twi = ts:Create(script.Parent.Glass, duration, goal)
twi:Play()
script.Parent.Indicator.BrickColor = BrickColor.Green()

wait(5)

local twi2 = ts:Create(script.Parent.Glass, duration, goal2)
twi2:Play()
script.Parent.Indicator.BrickColor = BrickColor.Red()

end)

3 Likes

Who did you buy it from lmao.
Anyway, I know you want me to message you on discord but for some reason I can’t find you.
You will have to use if statements to check if a player is in the group

if Player:IsInGroup(IdHere) then
--do magic stuff
end
1 Like

Thanks, but I am trying to do it so it only works with certain ranks. It’s a door that leads to my interview center, so I am trying to make it so only certain ranks can open it so random people don’t just walk in mid-interview. My Discord is jake1260#3323

1 Like
if Player:GetRankInGroup(id) == # then
-stuff
elseif Player:GetRankInGroup(id) == # then
end
1 Like

It might be a bit neater to call the API once and store it in a local variable.

local rank = Player:GetRankInGroup( groupId )
if rank == # then
    -- stuff
elseif rank == ## then
    -- more stuff
end
1 Like

I don’t know anything about the script, so are you able to use the script I put, and just edit it to do what I want it to do?

1 Like

Perhaps this will help.

local Group = GROUP
local Rank = RANK

gl = script.Parent.MovingOne.Glass
duration = TweenInfo.new(1)
ts = game:GetService(“TweenService”)
script.Parent.Kontrolboks.ClickDetector.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(Group) >= Rank then
local goal = {}
goal.CFrame = script.Parent.Cel.CFrame

local goal2 = {}
goal2.CFrame = script.Parent.Cel2.CFrame

local twi = ts:Create(script.Parent.Glass, duration, goal)
twi:Play()
script.Parent.Indicator.BrickColor = BrickColor.Green()

wait(5)

local twi2 = ts:Create(script.Parent.Glass, duration, goal2)
twi2:Play()
script.Parent.Indicator.BrickColor = BrickColor.Red()
else
return
end
end)
1 Like

I mean it doesn’t really matter. If you want to use multiple groups then calling the API first would make it more complicated.

1 Like