Trying to script a Group only door - Proximity Prompt

Hello, I am currently trying to learn how to script and i ran into this problem:

attempt to index nil with ‘GetRankInGroup’

Heres the script:

local TweenService = game:GetService(“TweenService”)

local hinge = script.Parent.Doorframe.Hinge
local prompt = script.Parent.Base.ProximityPrompt

local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)

local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)

local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)

if player:GetRankInGroup(6856058) >= 255 then

prompt.Triggered:Connect(function()
if prompt.ActionText == “Close” then
tweenClose:Play()
prompt.ActionText = “Open”
else
tweenOpen:Play()
prompt.ActionText = “Close”
end
end)
end

1 Like

If this is the whole script, then I assume the problem is because you did not define player.

1 Like

@HappyC0der is correct. Place the if-statement with GetRankInGroup in the Triggered function. It is asking for the parameter which is who triggered the proximity prompt. Therefore…

…rewrite this section as:

prompt.Triggered:Connect(function(player)

      if player:IsInGroup(6856058) then

          if prompt.ActionText == “Close” then
          tweenClose:Play()
          prompt.ActionText = “Open”
      else
          tweenOpen:Play()
          prompt.ActionText = “Close”
       end
    else
       print(“Join the group next time you come here!”)
    end
end)

If it’s a group only door, use IsInGroup() instead. Or is there a reason you used GetRankInGroup()?