Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is the error coming up in output of :GetRankInGroup is a nil value?

I made a script to put inside an admin door and everytime I touched the door, it said in the output

attempt to index nil with 'GetRankInGroup'

So, I'm really confused, here is my script:

local adminDoor = script.Parent
local Players = game:GetService("Players")

adminDoor.Door.Touched:Connect(function(hit)
	local char = hit.Parent
	local player = Players:GetPlayerFromCharacter(char)
	
	local rank = player:GetRankInGroup(5567779)
	if rank >= 3 then
		game.ReplicatedStorage.AdminFound:FireClient(player)
	elseif rank < 3 then
		adminDoor.Door.CanCollide = true
	end
end)

1 answer

Maybe try this -

local adminDoor = script.Parent
ocal Players = game:GetService("Players")
 
adminDoor.Door.Touched:Connect(function(hit)
	    local char = hit.Parent
    local player = Players:GetPlayerFromCharacter(char)
	 
	    local rank = player:GetRankInGroup(5567779) >= 3 then
	        game.ReplicatedStorage.AdminFound:FireClient(player)
	    else
	        adminDoor.Door.CanCollide = true
	    end
	end)


This discussion is preserved as it was. New answers, comments, and votes are closed.