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

attempt to index nil with 'Team'?

Asked by 4 years ago

Hi, sorry if code is inefficient or error is obvious as only a beginner scripter.

I'm having issues with the error 'attempt to index nil with 'Team'.

The error lies on the line 4 (I've marked it for ease), the player is in a team and if I print a statement just before saying print(player.Team) it successfully prints the player's team.

Any ideas?

for i,v in pairs(doorGroup:GetChildren()) do
    v.Zone.Touched:Connect(function(hit)
        local player = game:GetService("Players"):FindFirstChild(hit.Parent.Name)
        if getAccess(v.Name,player.Team) then --this line
            openDoor(v,2)
        elseif hit.Parent:FindFirstChild("Lockpick") then
            if not(player.PlayerGui:FindFirstChild("LockpickGUI")) then
                game.ReplicatedStorage.Guis.LockpickGUI:Clone().Parent = player.PlayerGui
                repeat wait() until not(player.PlayerGui:FindFirstChild("LockpickGUI"))
                if hit.Parent:FindFirstChild("Lockpick") then
                    openDoor(v,10)
                end
            end
        end
    end)
end

Answer this question