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 5 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:

01local adminDoor = script.Parent
02local Players = game:GetService("Players")
03 
04adminDoor.Door.Touched:Connect(function(hit)
05    local char = hit.Parent
06    local player = Players:GetPlayerFromCharacter(char)
07 
08    local rank = player:GetRankInGroup(5567779)
09    if rank >= 3 then
10        game.ReplicatedStorage.AdminFound:FireClient(player)
11    elseif rank < 3 then
12        adminDoor.Door.CanCollide = true
13    end
14end)

1 answer

Log in to vote
0
Answered by 5 years ago

Maybe try this -

01local adminDoor = script.Parent
02ocal Players = game:GetService("Players")
03 
04adminDoor.Door.Touched:Connect(function(hit)
05        local char = hit.Parent
06    local player = Players:GetPlayerFromCharacter(char)
07 
08        local rank = player:GetRankInGroup(5567779) >= 3 then
09            game.ReplicatedStorage.AdminFound:FireClient(player)
10        else
11            adminDoor.Door.CanCollide = true
12        end
13    end)
Ad

Answer this question