script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.Team == "Red" then
script.Parent.Parent.RedOccupied.Value = script.Parent.Parent.RedOccupied.Value + 1
elseif player.Team == "Blue" then
script.Parent.Parent.BlueOccupied.Value = script.Parent.Parent.BlueOccupied.Value + 1
end
end)
Error:
00:29:15.515 - Workspace.MountainFlag.FlagTrigger.Script:3: attempt to index local 'player' (a nil value)

2 comments
You have to check if what touched the part was a player character part. (if player then)
Can you implement that into the script and post it as an answer so I can accept and fully understand what you mean?