My capture point script didn't work

Hello! My name is Wewez, and im making a capture point script, but it didnt work.
Here is the script:

script.Parent.Touched:Connect(function(part)
local Players = game:GetService(“Players”)
local player = Players:GetPlayerFromCharacter(part.Parent)

if player.Team == game.Teams.Red then
script.Parent.Status.Value = “Red”
script.Parent.BrickColor = BrickColor.new(“Really red”)

elseif player.Team == game.Teams.Blue then
script.Parent.Status.Value = “Blue”
script.Parent.BrickColor = BrickColor.new(“Really blue”)
end
end)

Output:

Workspace.PointA.Script:6: attempt to index nil with ‘Team’

player.Team.Name == "Red"
(limit)

Right after this line:
local player = Players:GetPlayerFromCharacter(part.Parent)

add this:
if player == nil then return end

If something other than a player’s body part touched the brick, then GetPlayerFromCharacter will return nil.
Sometimes the brick in one of your character’s accessories will trip it, and that will make player nil as well, unless you did GetPlayerFromCharacter(hit.Parent.Parent)

That’s why you should always add a check when it comes to .Touched events. Adding that line should fix it by stopping if there’s no player