So, I'm trying to get a group/rank only click detector, but I keep getting the Attempt to call A nil value error.

Snippet of the bit that is wrong

local dRank = 243
local gRank = 2739702
local player = clicky.MouseClick:connect(player)
clicky.MouseClick:connect(function(clicker)
	if player:IsInGroup(gRank) and player:GetRankInGroup(gRank) >= dRank then
--rest of code

The Error

16:23:19.470 - attempt to call a nil value
16:23:21.436 - IsInGroup is not a valid member
16:23:21.438 - Script 'Workspace.PrisionDoor.Door.DoorOpenScript', Line 12
16:23:21.440 - Stack End

Entire code

local WDoor = script.Parent
local clicky = WDoor.DoorHandle.OpenDoorClick
local doorOpen = false
local OCD = clicky.MaxActivationDistance
WDoor.PrimaryPart = WDoor.Parent.DoorHinge
local debounce = false
local LN = 0
local dRank = 243
local gRank = 2739702
local player = clicky.MouseClick:connect(player)
clicky.MouseClick:connect(function(clicker)
	if player:IsInGroup(gRank) and player:GetRankInGroup(gRank) >= dRank then
	if debounce then return end	
	debounce = true
	clicky.MaxActivationDistance = 0
	local RA = -135	
	local AC = -5
	if doorOpen then
		 RA = 0 
		 AC = -1 * AC
		end
	for i=LN,RA,AC do
		wait()
		WDoor:SetPrimaryPartCFrame(WDoor:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(AC), 0))
		LN = i
	end
	doorOpen = not doorOpen
	debounce = false
	clicky.MaxActivationDistance = OCD
	end
end)