Hey everyone.
I’ve done some messing around and I am still not able to find out what’s causing this error.
Any help would be appreciated.
This code right here keeps coming back to this error code: Workspace.Door.Script:10: attempt to index nil with ‘Team’ - Server - Script:10
local db = false
local open = script.Parent.Open
local ind = script.Parent.Door1
Teams = game:GetService("Teams")
script.Parent.Trigger.Touched:connect(function(p)
local Player = game.Players:GetPlayerFromCharacter(p.Parent)
if db == false then
db = true
if Player.Team == Teams["Guards"] or p.Parent:FindFirstChild("KeyCard") then -- this line
if open.Value == false then
local db = false
local open = script.Parent.Open
local ind = script.Parent.Door1
Teams = game:GetService("Teams")
script.Parent.Trigger.Touched:connect(function(p)
local Player = game.Players:GetPlayerFromCharacter(p.Parent)
if db == false then
db = true
if Player.Team == Teams["Guards"] or p.Parent:FindFirstChild("KeyCard") then -- this line
if open.Value == false then
You could try just checking if the Player was actually found
if Player ~= nil then
It could be considered better to write this as
if nil ~= Player then
This is because Player is the changing value and there is no risk of changing the value.
It could also be written as
if Player then
Just depends on your personal preference.
This might work for your case
2 Likes
Line 4
local Teams = game:GetService("Teams")
Or try this script:
local db = false
local opn = script.Parent.Open
local ind = script.Parent.Door1
local teams = game:GetService("Teams")
script.Parent.Trigger:Connect (function (p)
local h = p.Parent:FindFirstChild("Humanoid")
if h and not db then
db = true
local player = game:GetService("Players"):GetPlayerFromCharacter(p.Parent)
if Player.Team == Teams["Guards"] or p.Parent:FindFirstChild("KeyCard") then -- this line
if open.Value == false then
--your script