Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)


Ad

Answer this question